Embedding twitch in android app buffers indefinitely

Hey guys,

I am working on an app where you can watch a random streamer that you follow. I have embedded the twitch player with a web view. It almost works. What I mean by this, is if you hit pause, and then play, it works perfectly. But it will not work upon initial load. It will just keep buffering.

Here is my log:
D/AudioTrack: stop() called with 10721600 frames delivered
W/cr_MediaCodecBridge: Releasing: OMX.qcom.video.decoder.avc
I/chromium: [INFO:CONSOLE(0)] “The SSL certificate used to load resources from https://player.twitch.tv will be distrusted in the future. Once distrusted, users will be prevented from loading these resources. See https://g.co/chrome/symantecpkicerts for more information.”, source: https://player.twitch.tv/?channel=anthony_kongphan&html5 (0)
D/SurfaceUtils: disconnecting from surface 0x76ddf18010, reason disconnectFromSurface
W/cr_MediaCodecBridge: Codec released
I/chromium: [INFO:CONSOLE(28)] “setStatsEnabled has been deprecated.”, source: https://player.twitch.tv/js/player.1779a152828f4ec07cf6.js (28)
I/chromium: [INFO:CONSOLE(0)] “The SSL certificate used to load resources from https://api.twitch.tv will be distrusted in the future. Once distrusted, users will be prevented from loading these resources. See https://g.co/chrome/symantecpkicerts for more information.”, source: https://player.twitch.tv/?channel=anthony_kongphan&html5 (0)
I/chromium: [INFO:CONSOLE(28)] “failed to resolve properties promise”, source: https://player.twitch.tv/js/player.1779a152828f4ec07cf6.js (28)
I/chromium: [INFO:CONSOLE(28)] “failed to resolve properties promise”, source: https://player.twitch.tv/js/player.1779a152828f4ec07cf6.js (28)
I/chromium: [INFO:CONSOLE(1)] “localStorage not available:”, source: https://cvp.twitch.tv/2.2.404/mediaplayer.min.js (1)

The code:
WebView webView;
webView = findViewById(R.id.webView);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webView.loadUrl(url);

If anyone has any idea how I can fix this, I would greatly appreciate it. Thank you for reading.

&html5

You shouldn’t be using that parameter. It (at least used to) load a different version of the html5 player. Have you tried without it?

Thanks for the reply, I actually found the answer. I simply needed to add

webSettings.setMediaPlaybackRequiresUserGesture(false);

And you are correct, the html5 tag is not needed. I was just trying anything and everything i could xD

1 Like

Thanks for sharing your solution!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.