Skip to content
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

Add callback for Init Failure #248

Open
always-beta opened this issue Nov 5, 2018 · 8 comments
Open

Add callback for Init Failure #248

always-beta opened this issue Nov 5, 2018 · 8 comments

Comments

@always-beta
Copy link

Hi, thanks for the great library!

In YouTubePlayerInitListener, there is onInitSuccess callback which will be called after the iframe script from youtube being loaded, is there anyway I can detect the init fails due to the iframe script couldn't be loaded (maybe network issue)?
Seems like I can implement a timer to trigger after certain timeout but I'm wondering if there is a better and correct way of receiving the event.

Thanks.

@PierfrancescoSoffritti
Copy link
Owner

PierfrancescoSoffritti commented Nov 5, 2018

Hi, unfortunately it's not possible. There is no way of knowing if the iframe library download has failed.

YouTubePlayerView contains logic to handle connectivity problems, you can look there to see how it works! (look for the asyncInitialization field)

If you're finding this library to be useful consider leaving a star on Github :)

@always-beta
Copy link
Author

(Already starred 😄 )

Thanks for the quick reply, I found that on iOS youtube sdk, they used onerror of <script> tag to detect the script load failure (code).
<script src="https://www.youtube.com/iframe_api" onerror="window.location.href='ytplayer://onYouTubeIframeAPIFailedToLoad'"></script>

And it works fine in iOS and chrome on a Mac.

Is it possible we use the same mechanism on Android platform?

@PierfrancescoSoffritti
Copy link
Owner

Oh yeah, good idea. Yes, that should work!

@PierfrancescoSoffritti PierfrancescoSoffritti changed the title Callback for Init Failure Add callback for Init Failure Nov 8, 2018
@altaf2892
Copy link

Any Update to callback for Init Failure????

@PierfrancescoSoffritti
Copy link
Owner

Hi, @always-beta suggestion has yet to be implemented in the library.

@PierfrancescoSoffritti
Copy link
Owner

Hey @always-beta, can I ask for what use case would you need the init failure callback? At the moment the library automatically resolves init failures.

@always-beta
Copy link
Author

@PierfrancescoSoffritti

Hey, the use case would be like: our users are from all over the world including China where youtube can't be visited, and the iframe couldn't be loaded forever, in that case I'd like to notify users in time other than give no feedback to user.
I haven't upgraded to latest versions yet, can I ask how the library resolves the init failures automatically?

@PierfrancescoSoffritti
Copy link
Owner

I see, that makes sense.

I can try to do it over the weekend, but I can't guarantee I will have time. If you want, feel free to send a pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants