Upgrade ExoPlayer to 2.17.1 (#116)
* Upgrade ExoPlayer to 2.17.1 * Upgrade ExoPlayer FFmpeg extension to 2.17.1 * Revert subtitle and audio track buttons changes * Clean up layout files and code * Clean up activity_player.xml * Fix warnings about exo drawables overrides
This commit is contained in:
parent
f26cf2cf1a
commit
b50b7b985f
9 changed files with 103 additions and 90 deletions
|
@ -113,7 +113,7 @@ dependencies {
|
||||||
kapt("com.google.dagger:hilt-compiler:$hiltVersion")
|
kapt("com.google.dagger:hilt-compiler:$hiltVersion")
|
||||||
|
|
||||||
// ExoPlayer
|
// ExoPlayer
|
||||||
val exoplayerVersion = "2.16.1"
|
val exoplayerVersion = "2.17.1"
|
||||||
implementation("com.google.android.exoplayer:exoplayer-core:$exoplayerVersion")
|
implementation("com.google.android.exoplayer:exoplayer-core:$exoplayerVersion")
|
||||||
implementation("com.google.android.exoplayer:exoplayer-ui:$exoplayerVersion")
|
implementation("com.google.android.exoplayer:exoplayer-ui:$exoplayerVersion")
|
||||||
implementation(files("libs/extension-ffmpeg-release.aar"))
|
implementation(files("libs/extension-ffmpeg-release.aar"))
|
||||||
|
|
Binary file not shown.
|
@ -10,7 +10,7 @@ import android.widget.TextView
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.navigation.navArgs
|
import androidx.navigation.navArgs
|
||||||
import com.google.android.exoplayer2.C
|
import com.google.android.exoplayer2.C
|
||||||
import com.google.android.exoplayer2.SimpleExoPlayer
|
import com.google.android.exoplayer2.ExoPlayer
|
||||||
import com.google.android.exoplayer2.ui.TrackSelectionDialogBuilder
|
import com.google.android.exoplayer2.ui.TrackSelectionDialogBuilder
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import dev.jdtech.jellyfin.databinding.ActivityPlayerBinding
|
import dev.jdtech.jellyfin.databinding.ActivityPlayerBinding
|
||||||
|
@ -64,9 +64,9 @@ class PlayerActivity : BasePlayerActivity() {
|
||||||
|
|
||||||
val videoNameTextView = binding.playerView.findViewById<TextView>(R.id.video_name)
|
val videoNameTextView = binding.playerView.findViewById<TextView>(R.id.video_name)
|
||||||
|
|
||||||
viewModel.currentItemTitle.observe(this, { title ->
|
viewModel.currentItemTitle.observe(this) { title ->
|
||||||
videoNameTextView.text = title
|
videoNameTextView.text = title
|
||||||
})
|
}
|
||||||
|
|
||||||
val audioButton = binding.playerView.findViewById<ImageButton>(R.id.btn_audio_track)
|
val audioButton = binding.playerView.findViewById<ImageButton>(R.id.btn_audio_track)
|
||||||
val subtitleButton = binding.playerView.findViewById<ImageButton>(R.id.btn_subtitle)
|
val subtitleButton = binding.playerView.findViewById<ImageButton>(R.id.btn_subtitle)
|
||||||
|
@ -89,7 +89,7 @@ class PlayerActivity : BasePlayerActivity() {
|
||||||
"trackselectiondialog"
|
"trackselectiondialog"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is SimpleExoPlayer -> {
|
is ExoPlayer -> {
|
||||||
val mappedTrackInfo =
|
val mappedTrackInfo =
|
||||||
viewModel.trackSelector.currentMappedTrackInfo ?: return@setOnClickListener
|
viewModel.trackSelector.currentMappedTrackInfo ?: return@setOnClickListener
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ class PlayerActivity : BasePlayerActivity() {
|
||||||
"trackselectiondialog"
|
"trackselectiondialog"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is SimpleExoPlayer -> {
|
is ExoPlayer -> {
|
||||||
val mappedTrackInfo =
|
val mappedTrackInfo =
|
||||||
viewModel.trackSelector.currentMappedTrackInfo ?: return@setOnClickListener
|
viewModel.trackSelector.currentMappedTrackInfo ?: return@setOnClickListener
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ class PlayerActivity : BasePlayerActivity() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
viewModel.fileLoaded.observe(this, {
|
viewModel.fileLoaded.observe(this) {
|
||||||
if (it) {
|
if (it) {
|
||||||
audioButton.isEnabled = true
|
audioButton.isEnabled = true
|
||||||
audioButton.imageAlpha = 255
|
audioButton.imageAlpha = 255
|
||||||
|
@ -161,13 +161,13 @@ class PlayerActivity : BasePlayerActivity() {
|
||||||
speedButton.isEnabled = true
|
speedButton.isEnabled = true
|
||||||
speedButton.imageAlpha = 255
|
speedButton.imageAlpha = 255
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
viewModel.navigateBack.observe(this, {
|
viewModel.navigateBack.observe(this) {
|
||||||
if (it) {
|
if (it) {
|
||||||
onBackPressed()
|
onBackPressed()
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
viewModel.initializePlayer(args.items)
|
viewModel.initializePlayer(args.items)
|
||||||
hideSystemUI()
|
hideSystemUI()
|
||||||
|
|
|
@ -9,7 +9,7 @@ import android.view.View
|
||||||
import android.view.WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL
|
import android.view.WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL
|
||||||
import android.view.WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF
|
import android.view.WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF
|
||||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout
|
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout
|
||||||
import com.google.android.exoplayer2.ui.PlayerView
|
import com.google.android.exoplayer2.ui.StyledPlayerView
|
||||||
import dev.jdtech.jellyfin.PlayerActivity
|
import dev.jdtech.jellyfin.PlayerActivity
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
@ -17,7 +17,7 @@ import kotlin.math.abs
|
||||||
class PlayerGestureHelper(
|
class PlayerGestureHelper(
|
||||||
private val appPreferences: AppPreferences,
|
private val appPreferences: AppPreferences,
|
||||||
private val activity: PlayerActivity,
|
private val activity: PlayerActivity,
|
||||||
private val playerView: PlayerView,
|
private val playerView: StyledPlayerView,
|
||||||
private val audioManager: AudioManager
|
private val audioManager: AudioManager
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class PlayerGestureHelper(
|
||||||
|
|
||||||
override fun onSingleTapUp(e: MotionEvent?): Boolean {
|
override fun onSingleTapUp(e: MotionEvent?): Boolean {
|
||||||
playerView.apply {
|
playerView.apply {
|
||||||
if (!isControllerVisible) showController() else hideController()
|
if (!isControllerFullyVisible) showController() else hideController()
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,12 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".PlayerActivity">
|
tools:context=".PlayerActivity">
|
||||||
|
|
||||||
<com.google.android.exoplayer2.ui.PlayerView
|
<com.google.android.exoplayer2.ui.StyledPlayerView
|
||||||
android:id="@+id/player_view"
|
android:id="@+id/player_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/black"
|
android:background="@color/black"
|
||||||
|
app:animation_enabled="false"
|
||||||
app:show_buffering="always" />
|
app:show_buffering="always" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -18,12 +19,13 @@
|
||||||
android:layout_width="64dp"
|
android:layout_width="64dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical|start"
|
android:layout_gravity="center_vertical|start"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:background="@drawable/overlay_background"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_margin="16dp"
|
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:background="@drawable/overlay_background">
|
tools:visibility="visible">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/gesture_volume_text"
|
android:id="@+id/gesture_volume_text"
|
||||||
|
@ -31,7 +33,7 @@
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:layout_marginVertical="16dp"
|
android:layout_marginVertical="16dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textColor="@color/white"/>
|
android:textColor="@color/white" />
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/gesture_volume_progress_bar"
|
android:id="@+id/gesture_volume_progress_bar"
|
||||||
|
@ -39,7 +41,7 @@
|
||||||
android:layout_width="8dp"
|
android:layout_width="8dp"
|
||||||
android:layout_height="125dp"
|
android:layout_height="125dp"
|
||||||
android:progressDrawable="@drawable/progress_scale_drawable"
|
android:progressDrawable="@drawable/progress_scale_drawable"
|
||||||
android:progress="58"/>
|
tools:progress="58" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/gesture_volume_image"
|
android:id="@+id/gesture_volume_image"
|
||||||
|
@ -55,12 +57,13 @@
|
||||||
android:layout_width="64dp"
|
android:layout_width="64dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical|end"
|
android:layout_gravity="center_vertical|end"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:background="@drawable/overlay_background"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_margin="16dp"
|
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:background="@drawable/overlay_background">
|
tools:visibility="visible">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/gesture_brightness_text"
|
android:id="@+id/gesture_brightness_text"
|
||||||
|
@ -68,7 +71,7 @@
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:layout_marginVertical="16dp"
|
android:layout_marginVertical="16dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textColor="@color/white"/>
|
android:textColor="@color/white" />
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/gesture_brightness_progress_bar"
|
android:id="@+id/gesture_brightness_progress_bar"
|
||||||
|
@ -76,7 +79,7 @@
|
||||||
android:layout_width="8dp"
|
android:layout_width="8dp"
|
||||||
android:layout_height="125dp"
|
android:layout_height="125dp"
|
||||||
android:progressDrawable="@drawable/progress_scale_drawable"
|
android:progressDrawable="@drawable/progress_scale_drawable"
|
||||||
android:progress="58"/>
|
tools:progress="58" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/gesture_brightness_image"
|
android:id="@+id/gesture_brightness_image"
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<merge xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
tools:keep="@layout/exo_styled_player_view">
|
|
||||||
|
|
||||||
<com.google.android.exoplayer2.ui.AspectRatioFrameLayout android:id="@id/exo_content_frame"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="center">
|
|
||||||
|
|
||||||
<!-- Video surface will be inserted as the first child of the content frame. -->
|
|
||||||
|
|
||||||
<View android:id="@id/exo_shutter"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="@android:color/black"/>
|
|
||||||
|
|
||||||
<ImageView android:id="@id/exo_artwork"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:scaleType="fitXY"/>
|
|
||||||
|
|
||||||
<ProgressBar android:id="@id/exo_buffering"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:indeterminate="true"
|
|
||||||
android:layout_gravity="center"/>
|
|
||||||
|
|
||||||
<TextView android:id="@id/exo_error_message"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_marginBottom="@dimen/exo_error_message_margin_bottom"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textColor="@color/exo_white"
|
|
||||||
android:textSize="@dimen/exo_error_message_text_size"
|
|
||||||
android:lineSpacingMultiplier="1.1"
|
|
||||||
android:background="@drawable/exo_rounded_rectangle"
|
|
||||||
android:paddingLeft="@dimen/exo_error_message_text_padding_horizontal"
|
|
||||||
android:paddingRight="@dimen/exo_error_message_text_padding_horizontal"
|
|
||||||
android:paddingTop="@dimen/exo_error_message_text_padding_vertical"
|
|
||||||
android:paddingBottom="@dimen/exo_error_message_text_padding_vertical"/>
|
|
||||||
|
|
||||||
</com.google.android.exoplayer2.ui.AspectRatioFrameLayout>
|
|
||||||
|
|
||||||
<com.google.android.exoplayer2.ui.SubtitleView android:id="@id/exo_subtitles"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"/>
|
|
||||||
|
|
||||||
<FrameLayout android:id="@id/exo_ad_overlay"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"/>
|
|
||||||
|
|
||||||
<FrameLayout android:id="@id/exo_overlay"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"/>
|
|
||||||
|
|
||||||
<View android:id="@id/exo_controller_placeholder"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"/>
|
|
||||||
|
|
||||||
</merge>
|
|
|
@ -62,6 +62,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
android:background="@drawable/transparent_circle_background"
|
android:background="@drawable/transparent_circle_background"
|
||||||
|
android:contentDescription="@string/select_playback_speed"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:src="@drawable/ic_gauge"
|
android:src="@drawable/ic_gauge"
|
||||||
app:tint="@color/white" />
|
app:tint="@color/white" />
|
||||||
|
@ -126,7 +127,7 @@
|
||||||
android:src="@drawable/ic_rewind" />
|
android:src="@drawable/ic_rewind" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/exo_play"
|
android:id="@+id/exo_play_pause"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/circle_background"
|
android:background="@drawable/circle_background"
|
||||||
|
@ -177,7 +178,8 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingStart="8dp">
|
android:paddingStart="8dp"
|
||||||
|
android:paddingEnd="8dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/exo_position"
|
android:id="@+id/exo_position"
|
71
app/src/main/res/layout/exo_styled_player_view.xml
Normal file
71
app/src/main/res/layout/exo_styled_player_view.xml
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<com.google.android.exoplayer2.ui.AspectRatioFrameLayout
|
||||||
|
android:id="@id/exo_content_frame"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center">
|
||||||
|
|
||||||
|
<!-- Video surface will be inserted as the first child of the content frame. -->
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@id/exo_shutter"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@android:color/black" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@id/exo_artwork"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scaleType="fitXY"
|
||||||
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@id/exo_buffering"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:indeterminate="true" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@id/exo_error_message"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginBottom="64dp"
|
||||||
|
android:background="@drawable/overlay_background"
|
||||||
|
android:gravity="center"
|
||||||
|
android:lineSpacingMultiplier="1.1"
|
||||||
|
android:paddingLeft="12dp"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingRight="12dp"
|
||||||
|
android:paddingBottom="4dp"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
</com.google.android.exoplayer2.ui.AspectRatioFrameLayout>
|
||||||
|
|
||||||
|
<com.google.android.exoplayer2.ui.SubtitleView
|
||||||
|
android:id="@id/exo_subtitles"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@id/exo_ad_overlay"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@id/exo_overlay"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@id/exo_controller_placeholder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
</merge>
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
<drawable name="exo_styled_controls_play">@drawable/ic_play</drawable>
|
<drawable name="exo_styled_controls_play" tools:ignore="PrivateResource">@drawable/ic_play</drawable>
|
||||||
<drawable name="exo_styled_controls_pause">@drawable/ic_pause</drawable>
|
<drawable name="exo_styled_controls_pause" tools:ignore="PrivateResource">@drawable/ic_pause</drawable>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in a new issue