question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

must use surfaceView to play widevine sample via exoplayer?

See original GitHub issue

I am new to integrate Drm sample to exoplayer. I search from stackOverFlow about this error msg. But mentioned solution from stackOverFlow is to use surfaceView for playing Widevine test sample via exoplayer.

Error msg:

native window cannot handle protected buffers: the consumer should either be a hardware composer or support hardware protection

How to fix this error? does it lack the video codec?

even I play widevine sample via exoplayer + surfaceView, it is only able to play once. there is the related error msg below.

2021-02-26 19:54:22.726 10902-12069/org.noovo.vlc D/SurfaceUtils: connecting to surface 0x71cc1f3010, reason connectToSurface
2021-02-26 19:54:22.726 10902-12069/org.noovo.vlc I/MediaCodec: [OMX.qcom.video.decoder.avc.secure] setting surface generation to 11163653
2021-02-26 19:54:22.726 10902-12069/org.noovo.vlc D/SurfaceUtils: disconnecting from surface 0x71cc1f3010, reason connectToSurface(reconnect)
2021-02-26 19:54:22.726 10902-12069/org.noovo.vlc D/SurfaceUtils: connecting to surface 0x71cc1f3010, reason connectToSurface(reconnect)
2021-02-26 19:54:22.730 10902-12070/org.noovo.vlc E/SurfaceUtils: native window cannot handle protected buffers: the consumer should either be a hardware composer or support hardware protection
2021-02-26 19:54:22.732 836-2253/? D/BufferQueueProducer: About to force-disconnect API_MEDIA, mode=1
2021-02-26 19:54:22.736 836-2253/? E/SurfaceFlinger: Failed to find layer (SurfaceView - org.noovo.vlc/com.example.noovo_gsyplayer.noovo_v2.ui.DrmTestPlayerActivity#0) in layer parent (no-parent).
2021-02-26 19:54:22.738 836-2390/? E/SurfaceFlinger: Failed to find layer (Background for - SurfaceView - org.noovo.vlc/com.example.noovo_gsyplayer.noovo_v2.ui.DrmTestPlayerActivity#0) in layer parent (no-parent).
2021-02-26 19:54:22.738 1719-8091/? I/MediaFocusControl:  AudioFocus  abandonAudioFocus() from uid/pid 10171/10902 clientId=android.media.AudioManager@9aa2d89com.shuyu.gsyvideoplayer.video.base.GSYVideoView$1@4deb903
2021-02-26 19:54:22.739 10902-12056/org.noovo.vlc E/ExoPlayerImplInternal: Playback error
      com.google.android.exoplayer2.ExoPlaybackException: Unexpected runtime error
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:564)
        at android.os.Handler.dispatchMessage(Handler.java:101)
        at android.os.Looper.loop(Looper.java:164)
        at android.os.HandlerThread.run(HandlerThread.java:65)
     Caused by: android.media.MediaCodec$CodecException: Error 0xffffffff
        at android.media.MediaCodec.native_setSurface(Native Method)
        at android.media.MediaCodec.setOutputSurface(MediaCodec.java:1954)
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.setOutputSurfaceV23(MediaCodecVideoRenderer.java:1242)
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.setSurface(MediaCodecVideoRenderer.java:516)
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.handleMessage(MediaCodecVideoRenderer.java:478)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.deliverMessage(ExoPlayerImplInternal.java:1402)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.sendMessageToTarget(ExoPlayerImplInternal.java:1368)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.sendMessageInternal(ExoPlayerImplInternal.java:1343)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:499)
        at android.os.Handler.dispatchMessage(Handler.java:101) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.os.HandlerThread.run(HandlerThread.java:65) 

I reference the widevine sample from https://integration.widevine.com/player

test sample: https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears.mpd license url: https://proxy.staging.widevine.com/proxy

drmSessionManager =
                    DefaultDrmSessionManager.Builder()
                        //keyRequest 很重要
                        .setKeyRequestParameters(mapOf(
                            "MDAwMDAwMDAwMDAwMDAwMQ==" to "eKHcBkYRlwfpA1FNigBzXw==",
                            "MDAwMDAwMDAwMDAwMDAwMw==" to "QkZshCrBxUObHgwJ+7Th0g==",
                            "MDAwMDAwMDAwMDAwMDAwMg==" to "Hzeeo4xw5Af3ayPsZAHK7w==",
                            "MDAwMDAwMDAwMDAwMDAwMA==" to "Pwoz80CYueIrwHjgobXoVA==",
                            "MDAwMDAwMDAwMDAwMDAwNA==" to "IvCfhLVopdAH5LHRFpQ1gQ==",
                            "MDAwMDAwMDAwMDAwMDAwNQ==" to "msMDbgSsnSvpRu1iQFFJvA==",
                            "MDAwMDAwMDAwMDAwMDAwNg==" to "MUWYWCQzTsTLSsS9w+K+7w==",
                            "MDAwMDAwMDAwMDAwMDAwNw==" to "ebhzT7mNJ1qQempaFQEouw=="
                        ))
                        .build(HttpMediaDrmCallback("https://proxy.staging.widevine.com/proxy", DefaultHttpDataSourceFactory("user-agent")))

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
icbakercommented, Mar 10, 2021

Glad you got it sorted! 😃

0reactions
dendrocytecommented, Mar 10, 2021

The demo app and your advise help me a lot! I fix the bug in my app after comparing from demo app: ‘even I play widevine sample via exoplayer + surfaceView, it is only able to play once’ -> does not re-build drmSessionManager ‘native window cannot handle protected buffers: the consumer should either be a hardware composer or support hardware protection’ -> does not stopPlayback when remove the surface

You can close the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exoplayer Tutorial: How to Stream Videos Securely on Android?
We will create a simple exoplayer application to play a video using MediaItem. The steps to implement Exoplayer are as follows:.
Read more >
android - How to use TextureView instead of SurfaceView with ...
The general recommendation is to use a SurfaceView , but there are nuances ... If you don't need to set the surface/texture view...
Read more >
Quick Guide: Integrating Widevine DRM In ExoPlayer For ...
Play the DRM-protected video in the native ExoPlayer with the help of Azure Media Service.
Read more >
Android: Choosing a Video View
Since Android's ExoPlayer does not support Widevine Classic, you should use Widevine Modular. The BrightcoveVideoView uses the Android Media ...
Read more >
Widevine Android SDK Guide | PallyCon Docs Home
PallyCon Widevine Android SDK uses Google ExoPlayer internally. ... This video is a tutorial for playing DRM content using the sample ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found