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