Skip to content

Commit

Permalink
fix(pip): pause when quitting pip
Browse files Browse the repository at this point in the history
 * update chapter ui when position updates
 * use HW+ by default
  • Loading branch information
abdallahmehiz committed Jul 26, 2024
1 parent 6c97f9c commit fdf7caa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/live/mehiz/mpvkt/di/PreferencesModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import live.mehiz.mpvkt.preferences.preference.AndroidPreferenceStore
import live.mehiz.mpvkt.preferences.preference.PreferenceStore
import org.koin.android.ext.koin.androidContext
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.bind
import org.koin.dsl.module

val PreferencesModule = module {
single<PreferenceStore> { AndroidPreferenceStore(androidContext()) }
single { AndroidPreferenceStore(androidContext()) }.bind(PreferenceStore::class)

singleOf(::AppearancePreferences)
singleOf(::PlayerPreferences)
Expand Down
11 changes: 9 additions & 2 deletions app/src/main/java/live/mehiz/mpvkt/ui/player/PlayerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ class PlayerActivity : AppCompatActivity() {
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if (isInPictureInPictureMode) return
else viewModel.pause()
} else {
viewModel.pause()
}
viewModel.pause()
}

override fun onUserLeaveHint() {
Expand Down Expand Up @@ -172,7 +174,7 @@ class PlayerActivity : AppCompatActivity() {
}
MPVLib.setPropertyString(
"hwdec",
if (decoderPreferences.tryHWDecoding.get()) "auto-copy" else "no",
if (decoderPreferences.tryHWDecoding.get()) "auto" else "no",
)
when (decoderPreferences.debanding.get()) {
Debanding.None -> {}
Expand Down Expand Up @@ -399,8 +401,12 @@ class PlayerActivity : AppCompatActivity() {
fileName,
if (playerPreferences.savePositionOnQuit.get()) player.timePos ?: 0 else 0,
player.sid,
MPVLib.getPropertyDouble("sub-delay"),
MPVLib.getPropertyDouble("sub-speed"),
player.secondarySid,
MPVLib.getPropertyDouble("secondary-sub-delay"),
player.aid,
MPVLib.getPropertyDouble("audio-delay")
),
)
}
Expand Down Expand Up @@ -469,6 +475,7 @@ class PlayerActivity : AppCompatActivity() {
viewModel.hideSeekBar()
viewModel.isBrightnessSliderShown.update { false }
viewModel.isVolumeSliderShown.update { false }
viewModel.sheetShown.update { Sheets.None }
pipReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
if (intent == null || intent.action != PIP_INTENTS_FILTER) return
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/live/mehiz/mpvkt/ui/player/PlayerEnums.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ enum class VideoAspect(@StringRes val titleRes: Int) {
}

enum class Decoder(val title: String, val value: String) {
Auto("Auto", "auto-copy"),
AutoCopy("Auto", "auto-copy"),
Auto("Auto", "auto"),
SW("SW", "no"),
HW("HW", "mediacodec-copy"),
HWPlus("HW+", "mediacodec"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class PlayerViewModel(
Decoder.HWPlus -> Decoder.HW.value
Decoder.HW -> Decoder.SW.value
Decoder.SW -> Decoder.HWPlus.value
Decoder.AutoCopy -> Decoder.SW.value
Decoder.Auto -> Decoder.SW.value
},
)
Expand Down Expand Up @@ -221,6 +222,7 @@ class PlayerViewModel(

fun updatePlayBackPos(pos: Float) {
_pos.update { pos }
updateChapter(pos.toLong())
}

fun updateReadAhead(value: Long) {
Expand Down

0 comments on commit fdf7caa

Please sign in to comment.