Clean up
This commit is contained in:
parent
7c995f14bb
commit
39f3bd2656
8 changed files with 63 additions and 62 deletions
|
@ -13,9 +13,9 @@ I am developing this application in my spare time.
|
||||||
|
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
Home | Library | Movie | Season | Episode
|
| Home | Library | Movie | Season | Episode |
|
||||||
-----|---------|-------|--------|--------
|
|-------------------------------------|-------------------------------------|---------------------------------|-----------------------------------|-------------------------------------|
|
||||||
 |  |  |  | 
|
|  |  |  |  |  |
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Completely native interface
|
- Completely native interface
|
||||||
|
|
|
@ -127,9 +127,9 @@ class MPVPlayer(
|
||||||
if (requestAudioFocus) {
|
if (requestAudioFocus) {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
audioFocusRequest = audioManager.requestAudioFocus(
|
audioFocusRequest = audioManager.requestAudioFocus(
|
||||||
/* listener= */ this,
|
/* l = */ this,
|
||||||
/* streamType= */ AudioManager.STREAM_MUSIC,
|
/* streamType = */ AudioManager.STREAM_MUSIC,
|
||||||
/* durationHint= */ AudioManager.AUDIOFOCUS_GAIN
|
/* durationHint = */ AudioManager.AUDIOFOCUS_GAIN
|
||||||
)
|
)
|
||||||
if (audioFocusRequest != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
|
if (audioFocusRequest != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
|
||||||
MPVLib.setPropertyBoolean("pause", true)
|
MPVLib.setPropertyBoolean("pause", true)
|
||||||
|
@ -142,7 +142,7 @@ class MPVPlayer(
|
||||||
context.mainLooper,
|
context.mainLooper,
|
||||||
Clock.DEFAULT
|
Clock.DEFAULT
|
||||||
) { listener: Player.Listener, flags: FlagSet ->
|
) { listener: Player.Listener, flags: FlagSet ->
|
||||||
listener.onEvents( /* player= */this, Player.Events(flags))
|
listener.onEvents( /* player = */this, Player.Events(flags))
|
||||||
}
|
}
|
||||||
private val videoListeners =
|
private val videoListeners =
|
||||||
CopyOnWriteArraySet<Player.Listener>()
|
CopyOnWriteArraySet<Player.Listener>()
|
||||||
|
@ -336,7 +336,7 @@ class MPVPlayer(
|
||||||
playerStateChanged = true
|
playerStateChanged = true
|
||||||
}
|
}
|
||||||
if (playerStateChanged) {
|
if (playerStateChanged) {
|
||||||
listeners.queueEvent( /* eventFlag= */ C.INDEX_UNSET) { listener ->
|
listeners.queueEvent( /* eventFlag = */ C.INDEX_UNSET) { listener ->
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
listener.onPlayerStateChanged(playWhenReady, playbackState)
|
listener.onPlayerStateChanged(playWhenReady, playbackState)
|
||||||
}
|
}
|
||||||
|
@ -359,13 +359,12 @@ class MPVPlayer(
|
||||||
fun selectTrack(
|
fun selectTrack(
|
||||||
@TrackType trackType: String,
|
@TrackType trackType: String,
|
||||||
id: Int
|
id: Int
|
||||||
): Boolean {
|
) {
|
||||||
if (id != C.INDEX_UNSET) {
|
if (id != C.INDEX_UNSET) {
|
||||||
MPVLib.setPropertyInt(trackType, id)
|
MPVLib.setPropertyInt(trackType, id)
|
||||||
} else {
|
} else {
|
||||||
MPVLib.setPropertyString(trackType, "no")
|
MPVLib.setPropertyString(trackType, "no")
|
||||||
}
|
}
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timeline wrapper
|
// Timeline wrapper
|
||||||
|
@ -394,20 +393,20 @@ class MPVPlayer(
|
||||||
val currentMediaItem =
|
val currentMediaItem =
|
||||||
internalMediaItems.getOrNull(windowIndex) ?: MediaItem.Builder().build()
|
internalMediaItems.getOrNull(windowIndex) ?: MediaItem.Builder().build()
|
||||||
return window.set(
|
return window.set(
|
||||||
/* uid= */ windowIndex,
|
/* uid = */ windowIndex,
|
||||||
/* mediaItem= */ currentMediaItem,
|
/* mediaItem = */ currentMediaItem,
|
||||||
/* manifest= */ null,
|
/* manifest = */ null,
|
||||||
/* presentationStartTimeMs= */ C.TIME_UNSET,
|
/* presentationStartTimeMs = */ C.TIME_UNSET,
|
||||||
/* windowStartTimeMs= */ C.TIME_UNSET,
|
/* windowStartTimeMs = */ C.TIME_UNSET,
|
||||||
/* elapsedRealtimeEpochOffsetMs= */ C.TIME_UNSET,
|
/* elapsedRealtimeEpochOffsetMs = */ C.TIME_UNSET,
|
||||||
/* isSeekable= */ isSeekable,
|
/* isSeekable = */ isSeekable,
|
||||||
/* isDynamic= */ !isSeekable,
|
/* isDynamic = */ !isSeekable,
|
||||||
/* liveConfiguration= */ currentMediaItem.liveConfiguration,
|
/* liveConfiguration = */ currentMediaItem.liveConfiguration,
|
||||||
/* defaultPositionUs= */ C.TIME_UNSET,
|
/* defaultPositionUs = */ C.TIME_UNSET,
|
||||||
/* durationUs= */ Util.msToUs(currentDurationMs ?: C.TIME_UNSET),
|
/* durationUs = */ Util.msToUs(currentDurationMs ?: C.TIME_UNSET),
|
||||||
/* firstPeriodIndex= */ windowIndex,
|
/* firstPeriodIndex = */ windowIndex,
|
||||||
/* lastPeriodIndex= */ windowIndex,
|
/* lastPeriodIndex = */ windowIndex,
|
||||||
/* positionInFirstPeriodUs= */ C.TIME_UNSET
|
/* positionInFirstPeriodUs = */ C.TIME_UNSET
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,11 +429,11 @@ class MPVPlayer(
|
||||||
*/
|
*/
|
||||||
override fun getPeriod(periodIndex: Int, period: Period, setIds: Boolean): Period {
|
override fun getPeriod(periodIndex: Int, period: Period, setIds: Boolean): Period {
|
||||||
return period.set(
|
return period.set(
|
||||||
/* id= */ periodIndex,
|
/* id = */ periodIndex,
|
||||||
/* uid= */ periodIndex,
|
/* uid = */ periodIndex,
|
||||||
/* windowIndex= */ periodIndex,
|
/* windowIndex = */ periodIndex,
|
||||||
/* durationUs= */ Util.msToUs(currentDurationMs ?: C.TIME_UNSET),
|
/* durationUs = */ Util.msToUs(currentDurationMs ?: C.TIME_UNSET),
|
||||||
/* positionInWindowUs= */ 0
|
/* positionInWindowUs = */ 0
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1394,39 +1393,42 @@ class MPVPlayer(
|
||||||
trackListText.removeFirst()
|
trackListText.removeFirst()
|
||||||
}
|
}
|
||||||
if (trackListVideo.isNotEmpty()) {
|
if (trackListVideo.isNotEmpty()) {
|
||||||
with(TrackGroup(*trackListVideo.toTypedArray())) {
|
trackGroups.add(
|
||||||
Tracks.Group(
|
with(TrackGroup(*trackListVideo.toTypedArray())) {
|
||||||
this,
|
Tracks.Group(
|
||||||
true,
|
this,
|
||||||
IntArray(this.length) { C.FORMAT_HANDLED },
|
true,
|
||||||
BooleanArray(this.length) { it == indexCurrentVideo }
|
IntArray(this.length) { C.FORMAT_HANDLED },
|
||||||
)
|
BooleanArray(this.length) { it == indexCurrentVideo }
|
||||||
}
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
if (trackListAudio.isNotEmpty()) {
|
if (trackListAudio.isNotEmpty()) {
|
||||||
with(TrackGroup(*trackListAudio.toTypedArray())) {
|
trackGroups.add(
|
||||||
Tracks.Group(
|
with(TrackGroup(*trackListAudio.toTypedArray())) {
|
||||||
this,
|
Tracks.Group(
|
||||||
true,
|
this,
|
||||||
IntArray(this.length) { C.FORMAT_HANDLED },
|
true,
|
||||||
BooleanArray(this.length) { it == indexCurrentAudio }
|
IntArray(this.length) { C.FORMAT_HANDLED },
|
||||||
)
|
BooleanArray(this.length) { it == indexCurrentAudio }
|
||||||
}
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
if (trackListText.isNotEmpty()) {
|
if (trackListText.isNotEmpty()) {
|
||||||
with(TrackGroup(*trackListText.toTypedArray())) {
|
trackGroups.add(
|
||||||
Tracks.Group(
|
with(TrackGroup(*trackListText.toTypedArray())) {
|
||||||
this,
|
Tracks.Group(
|
||||||
true,
|
this,
|
||||||
IntArray(this.length) { C.FORMAT_HANDLED },
|
true,
|
||||||
BooleanArray(this.length) { it == indexCurrentText }
|
IntArray(this.length) { C.FORMAT_HANDLED },
|
||||||
)
|
BooleanArray(this.length) { it == indexCurrentText }
|
||||||
}
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
if (trackGroups.isNotEmpty()) {
|
if (trackGroups.isNotEmpty()) {
|
||||||
tracks = Tracks(trackGroups)
|
tracks = Tracks(trackGroups)
|
||||||
}
|
}
|
||||||
} catch (e: JSONException) {
|
} catch (_: JSONException) {
|
||||||
}
|
}
|
||||||
return Pair(mpvTracks, tracks)
|
return Pair(mpvTracks, tracks)
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ internal class MediaDetailFragment : Fragment() {
|
||||||
// Check icon
|
// Check icon
|
||||||
when (played) {
|
when (played) {
|
||||||
true -> {
|
true -> {
|
||||||
if (played) binding.checkButton.imageTintList = ColorStateList.valueOf(
|
binding.checkButton.imageTintList = ColorStateList.valueOf(
|
||||||
resources.getColor(
|
resources.getColor(
|
||||||
R.color.red,
|
R.color.red,
|
||||||
requireActivity().theme
|
requireActivity().theme
|
||||||
|
|
|
@ -217,10 +217,8 @@ suspend fun syncPlaybackProgress(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localPlaybackProgress != null) {
|
if (localPlaybackProgress != null) {
|
||||||
if (localPlaybackProgress > playbackProgress) {
|
playbackProgress = localPlaybackProgress
|
||||||
playbackProgress = localPlaybackProgress
|
playedPercentage = localPlayedPercentage!!
|
||||||
playedPercentage = localPlayedPercentage!!
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (remotePlaybackProgress != null) {
|
if (remotePlaybackProgress != null) {
|
||||||
if (remotePlaybackProgress > playbackProgress) {
|
if (remotePlaybackProgress > playbackProgress) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package dev.jdtech.jellyfin.utils
|
package dev.jdtech.jellyfin.utils
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.media.AudioManager
|
import android.media.AudioManager
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import android.view.GestureDetector
|
import android.view.GestureDetector
|
||||||
|
@ -86,6 +87,7 @@ class PlayerGestureHelper(
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onScroll(firstEvent: MotionEvent, currentEvent: MotionEvent, distanceX: Float, distanceY: Float): Boolean {
|
override fun onScroll(firstEvent: MotionEvent, currentEvent: MotionEvent, distanceX: Float, distanceY: Float): Boolean {
|
||||||
if (firstEvent.y < playerView.resources.dip(Constants.GESTURE_EXCLUSION_AREA_TOP))
|
if (firstEvent.y < playerView.resources.dip(Constants.GESTURE_EXCLUSION_AREA_TOP))
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -130,7 +130,7 @@ constructor(
|
||||||
RecommendedServerInfoScore.BAD -> Unit
|
RecommendedServerInfoScore.BAD -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: CancellationException) {
|
} catch (_: CancellationException) {
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
_uiState.emit(
|
_uiState.emit(
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package dev.jdtech.jellyfin.viewmodels
|
package dev.jdtech.jellyfin.viewmodels
|
||||||
|
|
||||||
import androidx.lifecycle.LifecycleCoroutineScope
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
|
|
|
@ -41,7 +41,7 @@ class HomeViewModel @Inject internal constructor(
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
repository.postCapabilities()
|
repository.postCapabilities()
|
||||||
} catch (e: Exception) {
|
} catch (_: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue