feat: Updated exoplayer
This commit is contained in:
parent
528132c47d
commit
9c45c76ec0
|
@ -55,6 +55,12 @@ android {
|
|||
vectorDrawables {
|
||||
useSupportLibrary true
|
||||
}
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
|
||||
}
|
||||
}
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
|
@ -132,6 +138,9 @@ dependencies {
|
|||
implementation "com.google.android.exoplayer:exoplayer:$exo_player_version"
|
||||
implementation "com.google.android.exoplayer:exoplayer-core:$exo_player_version"
|
||||
implementation "com.google.android.exoplayer:exoplayer-hls:$exo_player_version"
|
||||
implementation "com.google.android.exoplayer:exoplayer-dash:$exo_player_version"
|
||||
implementation "com.google.android.exoplayer:exoplayer-rtsp:$exo_player_version"
|
||||
implementation "com.google.android.exoplayer:exoplayer-transformer:$exo_player_version"
|
||||
implementation "com.google.android.exoplayer:exoplayer-ui:$exo_player_version"
|
||||
|
||||
// Compose dependencies
|
||||
|
|
|
@ -16,6 +16,7 @@ import android.widget.FrameLayout
|
|||
import android.widget.ImageButton
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import com.google.android.exoplayer2.ui.StyledPlayerView
|
||||
import net.schueller.peertube.R
|
||||
import net.schueller.peertube.feature_video.presentation.video.events.VideoPlayEvent
|
||||
import net.schueller.peertube.feature_video.presentation.video.VideoPlayViewModel
|
||||
|
@ -58,7 +59,7 @@ fun VideoScreen(
|
|||
Log.v("VideoScreen", "playerView assign")
|
||||
|
||||
|
||||
PlayerView.switchTargetView(
|
||||
StyledPlayerView.switchTargetView(
|
||||
player,
|
||||
PlayerViewPool.currentPlayerView,
|
||||
playerView
|
||||
|
@ -78,7 +79,7 @@ fun VideoScreen(
|
|||
|
||||
|
||||
// Video More Button
|
||||
val videoMoreButton = playerView.findViewById<FrameLayout>(R.id.exo_more_button)
|
||||
val videoMoreButton = playerView.findViewById<ImageButton>(R.id.exo_more)
|
||||
videoMoreButton.setOnClickListener {
|
||||
viewModel.onEvent(VideoPlayEvent.MoreButton)
|
||||
}
|
||||
|
|
|
@ -4,22 +4,23 @@ import android.content.Context
|
|||
import android.view.LayoutInflater
|
||||
import androidx.core.util.Pools
|
||||
import com.google.android.exoplayer2.ui.PlayerView
|
||||
import com.google.android.exoplayer2.ui.StyledPlayerView
|
||||
import net.schueller.peertube.R
|
||||
|
||||
object PlayerViewPool {
|
||||
var currentPlayerView: PlayerView? = null
|
||||
var currentPlayerView: StyledPlayerView? = null
|
||||
|
||||
private val playerViewPool = Pools.SimplePool<PlayerView>(2)
|
||||
private val playerViewPool = Pools.SimplePool<StyledPlayerView>(2)
|
||||
|
||||
fun get(context: Context): PlayerView {
|
||||
fun get(context: Context): StyledPlayerView {
|
||||
return playerViewPool.acquire() ?: createPlayerView(context)
|
||||
}
|
||||
|
||||
fun release(player: PlayerView) {
|
||||
fun release(player: StyledPlayerView) {
|
||||
playerViewPool.release(player)
|
||||
}
|
||||
|
||||
private fun createPlayerView(context: Context): PlayerView {
|
||||
return (LayoutInflater.from(context).inflate(R.layout.exoplayer_texture_view, null, false) as PlayerView)
|
||||
private fun createPlayerView(context: Context): StyledPlayerView {
|
||||
return (LayoutInflater.from(context).inflate(R.layout.exoplayer_texture_view, null, false) as StyledPlayerView)
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.exoplayer2.ui.PlayerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<com.google.android.exoplayer2.ui.StyledPlayerView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/playerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -11,6 +13,7 @@
|
|||
app:show_buffering="when_playing"
|
||||
app:shutter_background_color="@android:color/black"
|
||||
app:surface_type="surface_view"
|
||||
app:show_subtitle_button="true"
|
||||
app:use_controller="true"
|
||||
android:animateLayoutChanges="true"
|
||||
app:controller_layout_id="@layout/video_playback_controls"
|
||||
|
|
|
@ -1,230 +1,131 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:background="#CC000000"
|
||||
android:layoutDirection="ltr"
|
||||
android:orientation="vertical"
|
||||
tools:targetApi="32">
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/exo_more_button"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_gravity="end">
|
||||
<View android:id="@id/exo_controls_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:background="@color/exo_black_opacity_60"/>
|
||||
|
||||
<ImageButton
|
||||
android:clickable="false"
|
||||
android:id="@+id/exo_more"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:background="@android:color/transparent"
|
||||
android:contentDescription="More"
|
||||
android:src="@drawable/ic_more_vertical"
|
||||
/>
|
||||
<FrameLayout android:id="@id/exo_bottom_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/exo_styled_bottom_bar_height"
|
||||
android:layout_marginTop="@dimen/exo_styled_bottom_bar_margin_top"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@color/exo_bottom_bar_background"
|
||||
android:layoutDirection="ltr">
|
||||
|
||||
<LinearLayout android:id="@id/exo_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/exo_styled_bottom_bar_time_padding"
|
||||
android:paddingEnd="@dimen/exo_styled_bottom_bar_time_padding"
|
||||
android:paddingLeft="@dimen/exo_styled_bottom_bar_time_padding"
|
||||
android:paddingRight="@dimen/exo_styled_bottom_bar_time_padding"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:layoutDirection="ltr">
|
||||
|
||||
<TextView android:id="@id/exo_position"
|
||||
style="@style/ExoStyledControls.TimeText.Position"/>
|
||||
|
||||
<TextView
|
||||
style="@style/ExoStyledControls.TimeText.Separator"/>
|
||||
|
||||
<TextView android:id="@id/exo_duration"
|
||||
style="@style/ExoStyledControls.TimeText.Duration"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:id="@id/exo_basic_controls"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:layoutDirection="ltr">
|
||||
|
||||
|
||||
<ImageButton android:id="@+id/exo_more"
|
||||
style="@style/ExoStyledControls.Button.Bottom.Settings"/>
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/exo_fullscreen_button"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="end">
|
||||
|
||||
<ImageButton
|
||||
android:clickable="false"
|
||||
android:id="@+id/exo_fullscreen_enable"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:background="@android:color/transparent"
|
||||
android:contentDescription="Fullscreen"
|
||||
android:src="@drawable/ic_maximize"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<ImageButton
|
||||
android:clickable="false"
|
||||
android:id="@+id/exo_fullscreen_disable"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:background="@android:color/transparent"
|
||||
android:contentDescription="Exit Fullscreen"
|
||||
android:src="@drawable/ic_maximize"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
|
||||
<Space
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
<View android:id="@id/exo_progress_placeholder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/exo_styled_progress_layout_height"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginBottom="@dimen/exo_styled_progress_margin_bottom"/>
|
||||
|
||||
<LinearLayout android:id="@id/exo_minimal_controls"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_marginBottom="@dimen/exo_styled_minimal_controls_margin_bottom"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="8dp">
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
<ImageButton
|
||||
android:id="@id/exo_rew"
|
||||
android:layout_width="72sp"
|
||||
android:layout_height="52sp"
|
||||
android:layout_gravity="start"
|
||||
android:background="@android:color/transparent"
|
||||
android:contentDescription="@string/exo_controls_rewind_description"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_rewind" />
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
<ImageButton
|
||||
android:id="@id/exo_repeat_toggle"
|
||||
style="@style/ExoMediaButton" />
|
||||
android:gravity="center_vertical"
|
||||
android:layoutDirection="ltr">
|
||||
|
||||
<ImageButton
|
||||
android:id="@id/exo_play"
|
||||
android:contentDescription="@string/exo_controls_play_description"
|
||||
android:src="@drawable/ic_play"
|
||||
android:layout_height="52sp"
|
||||
android:layout_width="72sp"
|
||||
android:scaleType="center"
|
||||
android:background="@android:color/transparent"
|
||||
/>
|
||||
<ImageButton android:id="@id/exo_minimal_fullscreen"
|
||||
style="@style/ExoStyledControls.Button.Bottom.FullScreen"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@id/exo_pause"
|
||||
android:contentDescription="@string/exo_controls_pause_description"
|
||||
android:src="@drawable/ic_pause"
|
||||
android:layout_height="52sp"
|
||||
android:layout_width="72sp"
|
||||
android:scaleType="center"
|
||||
android:background="@android:color/transparent"
|
||||
/>
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
<ImageButton
|
||||
android:id="@id/exo_ffwd"
|
||||
android:layout_width="72sp"
|
||||
android:layout_height="52sp"
|
||||
android:layout_gravity="end"
|
||||
android:background="@android:color/transparent"
|
||||
android:contentDescription="@string/exo_controls_fastforward_description"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_fast_forward" />
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<Space
|
||||
<LinearLayout
|
||||
android:id="@id/exo_center_controls"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:gravity="bottom"
|
||||
android:orientation="horizontal">
|
||||
android:layout_gravity="center"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="center"
|
||||
android:padding="@dimen/exo_styled_controls_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@id/exo_position"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:layout_gravity="center"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="14sp" />
|
||||
<ImageButton android:id="@id/exo_rew"
|
||||
style="@style/ExoStyledControls.Button.Center.RewWithAmount"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:textColor="#BABABA"
|
||||
android:textSize="14sp"
|
||||
android:includeFontPadding="false"
|
||||
android:text="@string/player_time_seperator" />
|
||||
<ImageButton android:id="@id/exo_play_pause"
|
||||
style="@style/ExoStyledControls.Button.Center.PlayPause"/>
|
||||
|
||||
<TextView
|
||||
android:id="@id/exo_duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:paddingStart="2dp"
|
||||
android:paddingEnd="6dp"
|
||||
android:textColor="#BABABA"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/exo_fullscreen_button"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="end">
|
||||
|
||||
<ImageButton
|
||||
android:clickable="false"
|
||||
android:id="@+id/exo_fullscreen_enable"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:background="@android:color/transparent"
|
||||
android:contentDescription="Fullscreen"
|
||||
android:src="@drawable/ic_maximize"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<ImageButton
|
||||
android:clickable="false"
|
||||
android:id="@+id/exo_fullscreen_disable"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:background="@android:color/transparent"
|
||||
android:contentDescription="Exit Fullscreen"
|
||||
android:src="@drawable/ic_maximize"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
|
||||
</FrameLayout>
|
||||
<ImageButton android:id="@id/exo_ffwd"
|
||||
style="@style/ExoStyledControls.Button.Center.FfwdWithAmount"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="-12dp"
|
||||
android:gravity="bottom"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
<com.google.android.exoplayer2.ui.DefaultTimeBar
|
||||
android:id="@id/exo_progress"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="26dp"
|
||||
android:layout_weight="1"
|
||||
app:played_color="?attr/colorPrimary" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- <LinearLayout-->
|
||||
<!-- android:visibility="gone"-->
|
||||
<!-- android:id="@+id/exo_torrent_status"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content">-->
|
||||
|
||||
<!-- <ProgressBar-->
|
||||
<!-- android:id="@+id/torrent_progress"-->
|
||||
<!-- style="?android:attr/progressBarStyleHorizontal"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:indeterminate="false"-->
|
||||
<!-- android:max="100" />-->
|
||||
|
||||
<!-- </LinearLayout>-->
|
||||
|
||||
</LinearLayout>
|
||||
</merge>
|
|
@ -3,7 +3,7 @@ buildscript {
|
|||
ext {
|
||||
compose_version = '1.2.0-alpha08'
|
||||
exo_player_version = '2.17.1'
|
||||
koltin_version = '1.6.10'
|
||||
koltin_version = '1.6.20'
|
||||
room_version = '2.4.2'
|
||||
}
|
||||
repositories {
|
||||
|
|
Loading…
Reference in New Issue