Twitch embedded video problem

When I embedded twitch player on android, it shows:

SafeMediaSource update error: DOMException: Failed to execute ‘appendBuffer’ on ‘SourceBuffer’: The HTMLMediaElement.error attribute is not null

StackOverFlow shows there’s some problem with the buffer. What can I do to fix that?

Hi, showing a snippet of the way you are embedding the video will help people help you more :wink:

Hi,

Here’s the code that I wrote:

 var options = {
		width : '100%',
		height : '100%',
		control : true,
		autoplay : true
	};
    player = new Twitch.Player("player", options);
    player.addEventListener(Twitch.Player.READY,function(event) {
    player.setVideo(id.toString());
    });

It’s wired that one is working and the other tablet is not working.

Error message:

Uncaught InvalidStateError: Failed to execute ‘appendBuffer’ on ‘SourceBuffer’: The HTMLMediaElement.error attribute is not null.
player-core-min.js:1 SafeMediaSource update error: DOMException: Failed to execute ‘appendBuffer’ on ‘SourceBuffer’: The HTMLMediaElement.error attribute is not null.
at Error (native)
at n._processUpdates (http://cvp.twitch.tv/1.8.8/player-core-min.js:1:860895)

Weird I tried something similar and it worked fine for me. You don’t really need to listen to an event, you can set a video id in the options using video parameter.

In the example below just replace the channel with video and put the value as the video id and it should work fine.

<script src= "http://player.twitch.tv/js/embed/v1.js"></script>
<div id="player"></div>
<script type="text/javascript">
	var options = {
		width: '100%',
		height: '100%',
		channel: 'lirik'
	};
	var player = new Twitch.Player("player", options);
</script>

What is id here?

Yes. It work on one tablet but not working on the other tablet.

I assume you are running this on a browser on your tablet or web view? What’s the client/browser you are using?

Yes. Both tablet is android device, on a webview.

id is v149444544. I assume id is correct cuz the video can be correctly played on one device.

1 Like

Don’t need to worry about the video id. It’s nothing to do with this because if it was you won’t be able to load this on one of the tablets.

You said you are using a webview on android. You can set a client for the webview and also enable JavaScript, do you do this? It could be that for one of the devices the settings default to something that works and on the other device the settings are different.

Yes. My setting code is:

videoWebView.getSettings().setJavaScriptEnabled(true);
videoWebView.getSettings().setDomStorageEnabled(true);
videoWebView.setWebChromeClient(bla bla bla);

That’s what I am thinking. Except for javascript enabled or Internet Stuffs, what else do we need to enable?

Hi,

I try to run the webview chrome version on those two device:

One is working with chrome/55,

One is not working with chrome/49.

Let me know if you have any idea! I believe this is relevant to the web browser version.

It looks like it’s an issue reported with chromes old version and was fixed in a update for chrome.

Try set another client on the webview and see if that works.

It seems to be a issue with the way chrome gets the buffer from the socket and tries to decode it.

Yes. So if it’s chrome version problem, how to fix that in the old version of chrome?

I believe some device are old(like using chrome 49) and twitch api should handle such condition.

It’s not a problem from Twitchs side. The problem was fixed in an update for Chrome.

You can either make this work:

  • The hard way - Write code to manage the buffer yourself (mainly empty the buffer for this problem I think)

OR

  • Easy way - Just use another client for your webview.

If another client doesn’t fix the problem then you will just need to stick to the first solution.

Do u have any ideas or starter code to handle the buffer myself?

You will have to read through the documentation at http://w3c.github.io/media-source/#widl-SourceBuffer-remove-void-double-start-unrestricted-double-end

Try to free up the buffer and appending new content to it and see if that work.

1 Like

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