KirovBvulgaru / google-cast-sdk

Automatically exported from code.google.com/p/google-cast-sdk
0 stars 0 forks source link

[Chrome] Make error-handling (in case of missing extension) easier. #124

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Currently there is no clear way to programmatically tell if the Cast API is 
still trying to initialize (`chrome.cast.isAvailable !== true`) or if it will 
never initialize because the Cast Extension is missing.

It would help a lot if a property like `chrome.cast.noExtension` could be set 
to true for this case.

That way initialization could wait for either `isAvailable` or `noExtension` to 
become true, and then react accordingly.

Attached a cast_sender.js with a small change (at the bottom) that would solve 
this issue.

It's possible to work with reasonable timeouts, but this solution seems 
nicer/cleaner to me :)

Original issue reported on code.google.com by scaryg...@gmail.com on 4 Feb 2014 at 11:23

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by anad...@google.com on 6 Feb 2014 at 4:41

GoogleCodeExporter commented 8 years ago
We already have an internal feature request similar to this.

Original comment by anad...@google.com on 6 Feb 2014 at 6:47

GoogleCodeExporter commented 8 years ago
there is also the bug that the "chrome" object never gets exposed to the global 
object when there is no chrome object predefined (e.g. browser != chrome). 

it would be nice to have a third state "wrong browser" besides "no extension" 
and "still loading extension"

Original comment by p...@zattoo.com on 13 Feb 2014 at 7:35

GoogleCodeExporter commented 8 years ago
I'd discovered that this is now possible with the latest beta extension 
(https://plus.google.com/+ShawnShen/posts/aVXSHyceNbR) and code something like 
this:

window.__onGCastApiAvailable = function (loaded, errorInfo) {
    if (loaded) {
        init();
    } else {
        handleError(errorInfo);
    }
};

if (!window.chrome) {
    // fire manually
    window.__onGCastApiAvailable(false, 'not in chrome browser');
}

Original comment by p...@zattoo.com on 21 Feb 2014 at 1:04

GoogleCodeExporter commented 8 years ago
I've forgot to add that the code needs to be executed before the chrome sender 
api library is loaded

Original comment by p...@zattoo.com on 21 Feb 2014 at 1:11

GoogleCodeExporter commented 8 years ago
Paul: you're right.

Original comment by shawns...@google.com on 21 Feb 2014 at 5:48