-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should unload method set src to empty string? #80
Comments
Good catch and thanks for the report. We'll take a look. |
@JobaDiniz , what browser and version are you using when it throws that error? I'm unable to reproduce in Chrome 43. |
Still don't have repro, but FWIW, I tried these ways as alternatives: delete video.src; // has no effect. video.src = null; // cast to a string, causes src to become a relative url to "null" video.removeAttribute('src'); // makes src attribute a blank string, but does not unload the original source |
Browser: |
Ah, I see. How frequently does this error occur? What OS are you on? |
OS: windows 8.1 |
I am seeing this same error every time when calling unload() Error thrown from : https://github.com/google/shaka-player/blob/master/lib/player/player.js#L231 |
@donato, are you getting a MEDIA_ERR_SRC_NOT_SUPPORTED error like @JobaDiniz? |
Yes. There are two versions of the error. I get this one when step debugging during _player.unload() : {
MediaError
code: 4
__proto__: MediaError
MEDIA_ERR_ABORTED: 1
MEDIA_ERR_DECODE: 3
MEDIA_ERR_NETWORK: 2
MEDIA_ERR_SRC_NOT_SUPPORTED: 4
} And this one when following the same steps without debugging
|
I'm testing right now with Chrome 43.0.2357.65 on OS X 10.10.3. I'm using the latest Shaka Player test app to load the manifest @donato mentioned. I load the video, let it play for a few seconds, then call app.player_.unload() from the JavaScript console. I'm unable to reproduce the problem. I've tried in both compiled & uncompiled modes. @donato, are you seeing the error in the Shaka Player test app? Or only in your own application? Are there other steps involved in repro than just loading a source and then calling unload a few seconds later? |
Hi @joeyparrish, I was able to reproduce the error in http://shaka-player-demo.appspot.com/. Before calling
After calling
|
@JobaDiniz, what's the value of video.error.code when this happens? |
4 |
@JobaDiniz, @donato, I finally see what's going on. This error is fired on video, but after Player has stopped listening for events. this.eventManager_.removeAll() runs before the source is unloaded, so the Player does not receive this event. As far as I can tell, this event is a completely harmless side-effect of the way we unload. Until we (not we=Google, but we=the internet) come up with a better way of unloading a video source to reuse the video tag, my recommendation is not to listen for errors on the video tag directly. Instead, listen for errors on Player. Listening on the Player will filter out errors you shouldn't have to care about, like this one, and it will allow you to receive lots of important errors that aren't dispatched through the video tag, like DASH-related or network-related errors. So this brings us back to the original topic: is it correct to unload this way? My feeling on the matter is that yes, it is okay to unload this way, but I am very open to alternatives. As mentioned in an earlier comment, I tried several alternatives already, to no avail:
If anyone has any other ideas, or if anyone can find a more canonically correct approach to unloading in a w3c doc somewhere, I would be happy to try it. |
So how is the correct approach to listen for errors? Is there a code
|
Listening to shaka player for errors is demonstrated here player.addEventListener('error', function(event) {
console.error(event);
}); |
It's very simple, and there's an example in app.js: player.addEventListener('error', function(event) {
console.error(event); // or whatever else you need to do with it
}); This pattern can be found in the test app and the samples in the tutorial. Would it be helpful to call this out more explicitly in the docs somewhere? |
I think it would. Thanks for the snippets. |
I'm going to close this for now. I've filed an issue to update the docs as #106. |
It was pointed out in #80 that setting video.src='', although common, is not best practice. I finally received some advice from w3c/media-source#53, specifically a pointer to the section "Best practices for authors using media elements" in the HTML5 spec. The solution is to use both removeAttribute('src') and load(). As determined during the investigation of #80, removeAttribute('src') alone is not effective. Change-Id: If0eb0dd2dc60dee0673dc92dabe9dc3e913457db
Is it ok to set the video src attribute to an empty string?
When I call unload method, html5 video player throws an error: MEDIA_ERR_SRC_NOT_SUPPORTED
This line of code sets src to empty string, but according to W3 this shouldn't be done:
The text was updated successfully, but these errors were encountered: