forked from hardcoresushi/DroidFS
Migrate to AndroidX Media3
This commit is contained in:
parent
217334a959
commit
4afe56b13c
@ -118,9 +118,10 @@ dependencies {
|
||||
implementation 'com.github.bumptech.glide:glide:4.15.1'
|
||||
implementation "androidx.biometric:biometric-ktx:1.2.0-alpha05"
|
||||
|
||||
def exoplayer_version = "2.19.1"
|
||||
implementation "com.google.android.exoplayer:exoplayer-core:$exoplayer_version"
|
||||
implementation "com.google.android.exoplayer:exoplayer-ui:$exoplayer_version"
|
||||
def media3_version = "1.1.1"
|
||||
implementation "androidx.media3:media3-exoplayer:$media3_version"
|
||||
implementation 'androidx.media3:media3-ui:1.1.1'
|
||||
implementation "androidx.media3:media3-datasource:$media3_version"
|
||||
|
||||
implementation "androidx.concurrent:concurrent-futures:1.1.0"
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
package sushi.hardcore.droidfs.file_viewers
|
||||
|
||||
import com.google.android.exoplayer2.ExoPlayer
|
||||
import androidx.annotation.OptIn
|
||||
import androidx.media3.common.util.UnstableApi
|
||||
import androidx.media3.exoplayer.ExoPlayer
|
||||
import sushi.hardcore.droidfs.databinding.ActivityAudioPlayerBinding
|
||||
|
||||
@OptIn(UnstableApi::class)
|
||||
class AudioPlayer: MediaPlayer(){
|
||||
private lateinit var binding: ActivityAudioPlayerBinding
|
||||
|
||||
|
@ -1,15 +1,19 @@
|
||||
package sushi.hardcore.droidfs.file_viewers
|
||||
|
||||
import android.net.Uri
|
||||
import com.google.android.exoplayer2.C
|
||||
import com.google.android.exoplayer2.upstream.DataSource
|
||||
import com.google.android.exoplayer2.upstream.DataSpec
|
||||
import com.google.android.exoplayer2.upstream.TransferListener
|
||||
import androidx.media3.common.C
|
||||
import androidx.annotation.OptIn
|
||||
import androidx.media3.common.util.UnstableApi
|
||||
import androidx.media3.datasource.DataSource
|
||||
import androidx.media3.datasource.DataSpec
|
||||
import androidx.media3.datasource.TransferListener
|
||||
import sushi.hardcore.droidfs.Constants
|
||||
import sushi.hardcore.droidfs.filesystems.EncryptedVolume
|
||||
import kotlin.math.min
|
||||
|
||||
class EncryptedVolumeDataSource(private val encryptedVolume: EncryptedVolume, private val filePath: String): DataSource {
|
||||
@OptIn(UnstableApi::class)
|
||||
class EncryptedVolumeDataSource(private val encryptedVolume: EncryptedVolume, private val filePath: String):
|
||||
DataSource {
|
||||
private var fileHandle = -1L
|
||||
private var fileOffset: Long = 0
|
||||
private var bytesRemaining: Long = -1
|
||||
|
@ -1,16 +1,22 @@
|
||||
package sushi.hardcore.droidfs.file_viewers
|
||||
|
||||
import android.view.WindowManager
|
||||
import com.google.android.exoplayer2.*
|
||||
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory
|
||||
import com.google.android.exoplayer2.source.MediaSource
|
||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource
|
||||
import com.google.android.exoplayer2.video.VideoSize
|
||||
import androidx.annotation.OptIn
|
||||
import androidx.media3.common.MediaItem
|
||||
import androidx.media3.common.PlaybackException
|
||||
import androidx.media3.common.Player
|
||||
import androidx.media3.common.VideoSize
|
||||
import androidx.media3.common.util.UnstableApi
|
||||
import androidx.media3.exoplayer.ExoPlayer
|
||||
import androidx.media3.exoplayer.source.MediaSource
|
||||
import androidx.media3.exoplayer.source.ProgressiveMediaSource
|
||||
import androidx.media3.extractor.DefaultExtractorsFactory
|
||||
import sushi.hardcore.droidfs.Constants
|
||||
import sushi.hardcore.droidfs.R
|
||||
import sushi.hardcore.droidfs.widgets.CustomAlertDialogBuilder
|
||||
import java.io.File
|
||||
|
||||
@OptIn(UnstableApi::class)
|
||||
abstract class MediaPlayer: FileViewerActivity() {
|
||||
private lateinit var player: ExoPlayer
|
||||
|
||||
|
@ -3,8 +3,8 @@ package sushi.hardcore.droidfs.file_viewers
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.res.Configuration
|
||||
import android.view.View
|
||||
import com.google.android.exoplayer2.ExoPlayer
|
||||
import com.google.android.exoplayer2.ui.StyledPlayerView
|
||||
import androidx.media3.exoplayer.ExoPlayer
|
||||
import androidx.media3.ui.PlayerView
|
||||
import sushi.hardcore.droidfs.databinding.ActivityVideoPlayerBinding
|
||||
|
||||
class VideoPlayer: MediaPlayer() {
|
||||
@ -19,7 +19,7 @@ class VideoPlayer: MediaPlayer() {
|
||||
setContentView(binding.root)
|
||||
applyNavigationBarMargin(binding.root)
|
||||
binding.videoPlayer.doubleTapOverlay = binding.doubleTapOverlay
|
||||
binding.videoPlayer.setControllerVisibilityListener(StyledPlayerView.ControllerVisibilityListener { visibility ->
|
||||
binding.videoPlayer.setControllerVisibilityListener(PlayerView.ControllerVisibilityListener { visibility ->
|
||||
binding.topBar.visibility = visibility
|
||||
if (visibility == View.VISIBLE) {
|
||||
showPartialSystemUi()
|
||||
|
@ -17,14 +17,14 @@ import android.widget.LinearLayout
|
||||
import androidx.core.view.GestureDetectorCompat
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.core.view.updatePadding
|
||||
import com.google.android.exoplayer2.ui.StyledPlayerView
|
||||
import androidx.media3.ui.PlayerView
|
||||
import sushi.hardcore.droidfs.R
|
||||
|
||||
class DoubleTapPlayerView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : StyledPlayerView(context, attrs, defStyleAttr) {
|
||||
) : PlayerView(context, attrs, defStyleAttr) {
|
||||
|
||||
companion object {
|
||||
const val SEEK_SECONDS = 10
|
||||
|
@ -15,11 +15,11 @@
|
||||
android:textSize="@dimen/title_text_size"
|
||||
android:padding="10dp"/>
|
||||
|
||||
<com.google.android.exoplayer2.ui.StyledPlayerControlView
|
||||
<androidx.media3.ui.PlayerControlView
|
||||
android:id="@+id/audio_controller"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:controller_layout_id="@layout/audio_exo_styled_player_control_view"
|
||||
app:controller_layout_id="@layout/audio_exo_player_control_view"
|
||||
app:show_timeout="0"
|
||||
app:show_shuffle_button="true"
|
||||
app:repeat_toggle_modes="all|one"/>
|
||||
|
@ -26,20 +26,20 @@
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="center"
|
||||
android:layoutDirection="ltr"
|
||||
android:padding="@dimen/exo_styled_controls_padding"
|
||||
android:layout_marginBottom="-40dp"
|
||||
android:clipToPadding="false">
|
||||
android:clipToPadding="false"
|
||||
android:layoutDirection="ltr"
|
||||
android:layout_marginBottom="-40dp">
|
||||
|
||||
<ImageButton android:id="@id/exo_prev"
|
||||
style="@style/ExoStyledControls.Button.Center.Previous"/>
|
||||
|
||||
<include layout="@layout/exo_styled_player_control_rewind_button" />
|
||||
<include layout="@layout/exo_player_control_rewind_button" />
|
||||
|
||||
<ImageButton android:id="@id/exo_play_pause"
|
||||
style="@style/ExoStyledControls.Button.Center.PlayPause"/>
|
||||
|
||||
<include layout="@layout/exo_styled_player_control_ffwd_button" />
|
||||
<include layout="@layout/exo_player_control_ffwd_button" />
|
||||
|
||||
<ImageButton android:id="@id/exo_next"
|
||||
style="@style/ExoStyledControls.Button.Center.Next"/>
|
@ -8,19 +8,19 @@
|
||||
android:layout_gravity="center"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="center"
|
||||
android:layoutDirection="ltr"
|
||||
android:padding="@dimen/exo_styled_controls_padding"
|
||||
android:clipToPadding="false">
|
||||
android:clipToPadding="false"
|
||||
android:layoutDirection="ltr">
|
||||
|
||||
<ImageButton android:id="@id/exo_prev"
|
||||
style="@style/ExoStyledControls.Button.Center.Previous"/>
|
||||
|
||||
<include layout="@layout/exo_styled_player_control_rewind_button" />
|
||||
<include layout="@layout/exo_player_control_rewind_button" />
|
||||
|
||||
<ImageButton android:id="@id/exo_play_pause"
|
||||
style="@style/ExoStyledControls.Button.Center.PlayPause"/>
|
||||
|
||||
<include layout="@layout/exo_styled_player_control_ffwd_button" />
|
||||
<include layout="@layout/exo_player_control_ffwd_button" />
|
||||
|
||||
<ImageButton android:id="@id/exo_next"
|
||||
style="@style/ExoStyledControls.Button.Center.Next"/>
|
||||
|
Loading…
Reference in New Issue
Block a user