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