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: Mediacodec error when switching from ffmpeg renderer to mediacodec renderer #785

Merged
merged 1 commit into from
Dec 19, 2023
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 @@ -15,6 +15,7 @@ import android.os.Build
import android.os.Bundle
import android.util.TypedValue
import android.view.KeyEvent
import android.view.SurfaceView
import android.view.View
import android.view.ViewGroup.LayoutParams
import android.view.WindowManager
Expand Down Expand Up @@ -139,6 +140,7 @@ class PlayerActivity : AppCompatActivity() {
private lateinit var playerGestureHelper: PlayerGestureHelper
private lateinit var playlistManager: PlaylistManager
private lateinit var trackSelector: DefaultTrackSelector
private var surfaceView: SurfaceView? = null
private var mediaSession: MediaSession? = null
private lateinit var playerApi: PlayerApi
private lateinit var volumeManager: VolumeManager
Expand Down Expand Up @@ -464,6 +466,11 @@ class PlayerActivity : AppCompatActivity() {
}

private fun playVideo(uri: Uri? = null) {
surfaceView = SurfaceView(this).apply {
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
}
player.setVideoSurfaceView(surfaceView)
exoContentFrameLayout.addView(surfaceView, 0)
lifecycleScope.launch(Dispatchers.IO) {
if (shouldFetchPlaylist) {
val mediaUri = getMediaContentUri(intent.data!!)
Expand Down
1 change: 1 addition & 0 deletions feature/player/src/main/res/layout/activity_player.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
android:background="@android:color/black"
app:animation_enabled="false"
app:show_buffering="always"
app:surface_type="none"
tools:foreground="@color/player_background" />

<LinearLayout
Expand Down