I 'm developing an application that allows you to continue receiving (like a browser) in the background Youtube video and audio through the YouTube Player API Reference for iframe Embeds in a WebView. When you're viewing a video, and turn off the screen with the power button, everything is still fine, but when I press the home button from the application, for a few seconds is perfectly listen, but then audio begins stuttering.
I tried to implement the WebView in a service, even with a floating overlay window, and all works, but the same thing happens when I press the home button, start stuttering audio and video (because in this case you can see the video too). Later, if I return to the application, all begin to work well again. It seems that app need to stay in foreground to work properly.
I've been trying different ideas, and I've been searching google for a week, but i dont know if this have a solution, the error is in Android 6.0, Android 5.0.2 working properly.
Here is the logcat for android 5.0.2 when i press home button:
W/cr_media: calling MediaCodec.release()
W/cr_media: calling MediaCodec.release()
E/OMXMaster: A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one.
W/linker: libaricentomxplugin.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
E/OMXMaster: A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one.
E/OMXNodeInstance: OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
E/ACodec: [OMX.google.vp9.decoder] storeMetaDataInBuffers failed w/ err -2147483648
E/OMXNodeInstance: getParameter(1868562439) ERROR: 0x8000101a
And the logcat for Android 6.0:
E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb8b429e0
D/AudioManager: AudioManager dispatching onAudioFocusChange(1) for android.media.AudioManager@7f0c8a8com.mzrsoftware.android.youparrot.WebViewerYoutube$3@898cfc1
W/cr_media: calling MediaCodec.release()
W/cr_media: calling MediaCodec.release()
W/OpenGLRenderer: Fail to change FontRenderer cache size, it already initialized
E/OMXMaster: A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one.
E/OMXMaster: Failed to get omx plugin handle
D/AudioManager: AudioManager dispatching onAudioFocusChange(-1) for android.media.AudioManager@7f0c8a8com.mzrsoftware.android.youparrot.WebViewerYoutube$3@898cfc1
E/OMXMaster: A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one.
E/OMXMaster: Failed to get omx plugin handle
W/OMXNodeInstance: [1:google.vp9.decoder] component does not support metadata mode; using fallback
E/ACodec: [OMX.google.vp9.decoder] storeMetaDataInBuffers failed w/ err -1010 / is-streaming 1
E/OMXNodeInstance: getParameter(1:google.vp9.decoder, ParamVideoAndroidVp8Encoder(0x6f600007)) ERROR: UnsupportedIndex(0x8000101a)
E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb8e1a248
-----(Here audio, video or both start stuttering)-----
W/OpenGLRenderer: Fail to change FontRenderer cache size, it already initialized
E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb8ed9ff0
Viewing logcat, and with what I found online, it seems to be a problem specific to Android 6.0 with buffers (buffer underrun), which may have been fixed in Android 6.0.1 , but I can not prove it.
Any solution for this?? Thanks!