Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Minor player fixes #885

Merged
merged 3 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ data class PlayerPreferences(
val useSystemCaptionStyle: Boolean = false,
val preferredSubtitleLanguage: String = "",
val subtitleTextEncoding: String = "",
val subtitleTextSize: Int = 23,
val subtitleTextSize: Int = 20,
val subtitleBackground: Boolean = false,
val subtitleFont: Font = Font.DEFAULT,
val subtitleTextBold: Boolean = true,
Expand Down
4 changes: 3 additions & 1 deletion core/ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,11 @@
<string name="properties">Properties</string>
<string name="volume_boost">Volume boost</string>
<string name="volume_boost_desc">Boost audio volume up to 200%</string>
<string name="open_subtitle">Open subtitle</string>
<string name="open_subtitle">Open local subtitle</string>
<string name="no_subtitle_tracks_found">Subtitle tracks for this video are either unavailable or not supported.</string>
<string name="no_audio_tracks_found">Audio tracks for this video are either unavailable or not supported.</string>
<string name="rename">Rename</string>
<string name="rename_to">Rename to</string>
<string name="exit">Exit</string>
<string name="play_next_video">Play next video</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import androidx.media3.session.MediaSession
import androidx.media3.ui.AspectRatioFrameLayout
import androidx.media3.ui.CaptionStyleCompat
import androidx.media3.ui.PlayerView
import androidx.media3.ui.SubtitleView
import androidx.media3.ui.TimeBar
import com.google.android.material.color.DynamicColors
import com.google.android.material.dialog.MaterialAlertDialogBuilder
Expand Down Expand Up @@ -311,8 +312,10 @@ class PlayerActivity : AppCompatActivity() {
@RequiresApi(Build.VERSION_CODES.O)
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) {
if (isInPictureInPictureMode) {
binding.playerView.subtitleView?.setFractionalTextSize(SubtitleView.DEFAULT_TEXT_SIZE_FRACTION)
playerUnlockControls.visibility = View.INVISIBLE
} else {
binding.playerView.subtitleView?.setFixedTextSize(TypedValue.COMPLEX_UNIT_SP, playerPreferences.subtitleTextSize.toFloat())
if (!isControlsLocked) {
playerUnlockControls.visibility = View.VISIBLE
}
Expand Down Expand Up @@ -514,7 +517,7 @@ class PlayerActivity : AppCompatActivity() {
val isCurrentUriIsFromIntent = intent.data == uri

viewModel.updateState(uri.toString())
if (isCurrentUriIsFromIntent && playerApi.hasPosition) {
if (isCurrentUriIsFromIntent && playerApi.hasPosition && viewModel.currentPlaybackPosition == null) {
viewModel.currentPlaybackPosition = playerApi.position?.toLong()
}

Expand Down Expand Up @@ -597,17 +600,19 @@ class PlayerActivity : AppCompatActivity() {

override fun onPlayerError(error: PlaybackException) {
Timber.e(error)
val alertDialog = MaterialAlertDialogBuilder(this@PlayerActivity)
.setTitle(getString(coreUiR.string.error_playing_video))
.setMessage(error.message ?: getString(coreUiR.string.unknown_error))
.setNegativeButton("CANCEL") { dialog, _ ->
dialog.dismiss()
val alertDialog = MaterialAlertDialogBuilder(this@PlayerActivity).apply {
setTitle(getString(coreUiR.string.error_playing_video))
setMessage(error.message ?: getString(coreUiR.string.unknown_error))
setNegativeButton(getString(coreUiR.string.exit)) { dialog, _ ->
finish()
}
.setPositiveButton("OK") { dialog, _ ->
dialog.dismiss()
if (playlistManager.hasNext()) playVideo(playlistManager.getNext()!!) else finish()
if (playlistManager.hasNext()) {
setPositiveButton(getString(coreUiR.string.play_next_video)) { dialog, _ ->
dialog.dismiss()
playVideo(playlistManager.getNext()!!)
}
}
.create()
}.create()

alertDialog.show()
super.onPlayerError(error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import androidx.compose.material3.SheetState
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.NonRestartableComposable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
Expand Down Expand Up @@ -129,7 +128,7 @@ fun OptionsBottomSheet(
ModalBottomSheet(
onDismissRequest = onDismiss,
sheetState = sheetState,
windowInsets = WindowInsets.none
windowInsets = WindowInsets(0)
) {
Column(
modifier = Modifier
Expand Down Expand Up @@ -167,8 +166,3 @@ fun BottomSheetItem(
.padding(vertical = 8.dp)
)
}

val WindowInsets.Companion.none: WindowInsets
@Composable
@NonRestartableComposable
get() = WindowInsets(0, 0, 0, 0)