androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.55k stars 373 forks source link

Compose TV, no video only audio playing #1649

Open alijamal6459 opened 3 weeks ago

alijamal6459 commented 3 weeks ago

ive tried full size screen, small size inside row, only plays audio and no video

works fine on google tv os but not on android tv os 11

  // Media3
    implementation(libs.androidx.media3.exoplayer)
    implementation(libs.androidx.media3.ui)
    implementation(libs.androidx.media3.exoplayer.hls)
    implementation(libs.androidx.media3.exoplayer.dash)
    val videoUri =
        Uri.parse("https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/WhatCarCanYouGetForAGrand.mp4");
    val context = LocalContext.current
    var isFullScreen by remember { mutableStateOf(false) }

    val exoPlayer = rememberExoPlayer(context)

    val mediaSource = remember(videoUri) {
        MediaItem.fromUri(videoUri)
    }

    LaunchedEffect(mediaSource) {
        exoPlayer.setMediaItem(mediaSource)
        exoPlayer.prepare()
        exoPlayer.play()
    }

    DisposableEffect(Unit) {
        onDispose {
            exoPlayer.release()
        }
    }

    Box(
        Modifier
            .focusable()
    ) {
        AndroidView(
            factory = {
                PlayerView(context).apply { useController = true }
            },
            update = { it.player = exoPlayer },
            onRelease = { exoPlayer.release() }
        )
    }
oceanjules commented 2 weeks ago

The use of the interop solution for compose (AndroidView + PlayerView) within Media3 has its limitations. However, it's hard to tell whether the problem is in the UI rendering or something is wrong with the media item.

Have you tried:

Janmurad commented 2 weeks ago

I have the same situation, sound is heard but video is not visible. I tested on Android emulator and physical device using media3.exoplayer version 1.4.0, it did not work on Android 11, it works on Android 14.

[ ] ExoPlayerImpl I Init 486642d [AndroidXMedia3/1.4.1] [generic_x86_arm, AOSP TV on x86, unknown, 30] [ ] com.my.tvplaye W Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (greylist, reflection, allowed) [ ] libc E Access denied finding property "vendor.display-size" [ ] Compose Focus D Owner FocusChanged(true) [ ] HostConnection D HostConnection::get() New Host Connection established 0xf2210e00, tid 2685 [ ] HostConnection D HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_sync_buffer_data ANDROID_EMU_vulkan_async_qsri ANDROID_EMU_read_color_buffer_dma GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2 [ ] OpenGLRenderer W Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... [ ] EGL_emulation D eglCreateContext: 0xf2211490: maj 2 min 0 rcv 2 [ ] EGL_emulation D eglMakeCurrent: 0xf2211490: ver 2 0 (tinfo 0xf2575c10) (first time) [ ] Gralloc4 I mapper 4.x is not supported [ ] HostConnection D createUnique: call [ ] HostConnection D HostConnection::get() New Host Connection established 0xf2213800, tid 2685 [ ] goldfish-address-space D allocate: Ask for block of size 0x100 [ ] goldfish-address-space D allocate: ioctl allocate returned offset 0x3fbffe000 size 0x2000 [ ] HostConnection D HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_sync_buffer_data ANDROID_EMU_vulkan_async_qsri ANDROID_EMU_read_color_buffer_dma GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2 [ ] OpenGLRenderer I Davey! duration=923ms; Flags=1, IntendedVsync=36253384611, Vsync=36353384607, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=36354798500, AnimationStart=36354811600, PerformTraversalsStart=36354983200, DrawStart=37131399000, SyncQueued=37136655800, SyncStart=37138569300, IssueDrawCommandsStart=37139230900, SwapBuffers=37170923000, FrameCompleted=37179228500, DequeueBufferDuration=6406300, QueueBufferDuration=620400, GpuCompleted=72904454231491230, [ ] Choreographer I Skipped 47 frames! The application may be doing too much work on its main thread. [ ] TetheringManager I registerTetheringEventCallback:com.my.tvplayer [ ] System W A resource failed to call close. [ ] VideoCapabilities I Unsupported profile 4 for video/mp4v-es [ ] ProfileInstaller D Installing profile for com.my.tvplayer [ ] OMXClient I IOmx service obtained [ ] SurfaceUtils D connecting to surface 0xecb4b068, reason connectToSurface [ ] MediaCodec I [OMX.google.h264.decoder] setting surface generation to 2712577 [ ] SurfaceUtils D disconnecting from surface 0xecb4b068, reason connectToSurface(reconnect) [ ] SurfaceUtils D connecting to surface 0xecb4b068, reason connectToSurface(reconnect) [ ] ACodec E [OMX.google.h264.decoder] setPortMode on output to DynamicANWBuffer failed w/ err -1010 [ ] ACodec I codec does not support config priority (err -1010) [ ] OMXClient I IOmx service obtained [ ] ACodec I codec does not support config priority (err -2147483648) [ ] ACodec I codec does not support config operating rate (err -2147483648) [ ] MediaCodec D [OMX.google.h264.decoder] setting dataspace on output surface to #104 [ ] SoftwareRenderer D setting dataspace on output surface to #104 [ ] AudioTrack D getTimestamp_l(15): device stall time corrected using current time 49642218000 [ ] SoftwareRenderer D setting dataspace on output surface to #103

Janmurad commented 2 weeks ago

I think I have solved this problem. After downgrading androidx.tv:tv-material library from version 1.0.0 to version 1.0.0-beta01, problem is in version 1.0.0. I you use this dependency androidx.tv:tv-material, downgrade it.

aman-jham commented 1 week ago

I am also face same issue for Android OS 14 TV devices playing the content correctly but in Android OS 11 TV devices (Ref 1.0 / 3.0) devices audio start but video frames started late rendering.

My observation is this only getting issue related with MP4 content other content format likeHLS, DASH is Playing correctly even in Android OS 11 TV devices.

androidx.media3:media3-exoplayer 1.4.1
androidx.tv:tv-material  1.0.0-alpha10
oceanjules commented 1 week ago

@aman-jham, could you upgrade androidx.tv:tv-material to 1.0.0-beta01 to see if it helps as @Janmurad suggested

pai-vignesh commented 13 hours ago

Yes. Even I was facing same issue. Only audio was playing no video. This issue occurred when I updated tv-material from 1.0.0-rc01 to stable 1.0.0.

Just revert it back to 1.0.0-rc01. Its working fine.