/    Sign up×
Community /Pin to ProfileBookmark

Youtube Chromless Player – Help

I am testing with the youtube chromeless player.

So far, not too bad…but I am not sure about something.

I can initiate the player to load the video and play it with an onclick event call…however, the same code called onload or just run in script tags, fails!

Can anyone help me understand why?

Here is the test page I’ve created:
[url]http://funmediadesign.com/tests/media[/url]

Thank you.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@astupidnameJun 22.2009 — however, the same code called onload or just run in script tags, fails![/quote]
It takes a bit of time, even after the window.onload event fires, for the player to be set-up. For example, the following will work if you replace the scriptlet at the bottom of your page with the following:
<script type="text/javascript">
swfobject.addLoadEvent(function () {
window.setTimeout(function () { loadNewVideo('1WlRcXIO5ik',0); },500);
}); //at 200ms IE sometimes won't load it yet
</script>


However, I don't think the above would be optimal, when you could invoke the call to loadNewVideo() within the onYouTubePlayerReady function instead of the above solution you could do this (also note, a global, undefined ytplayer variable declaration is necessary):
<script type="text/javascript">
var ytplayer;

<i> </i> function onYouTubePlayerReady(playerId) {
<i> </i> ytplayer = document.getElementById("myytplayer");
<i> </i> loadNewVideo('1WlRcXIO5ik',0);
<i> </i> }

<i> </i> // functions for the api calls
<i> </i> function loadNewVideo(id, startSeconds) {
<i> </i> if (ytplayer) {
<i> </i> ytplayer.loadVideoById(id, parseInt(startSeconds));
<i> </i> }
<i> </i> }
&lt;/script&gt;
Copy linkTweet thisAlerts:
@funmediadesignauthorJun 22.2009 — Hi

Adding
[CODE]loadNewVideo('1WlRcXIO5ik',0);[/CODE]

to the onYouTubePlayerReady function will work fine...

Haven't tested it, yet...but I'm 100% positive it will work.

Why didn't I think of this? A second pair of eyes helps.

Thank you for the help.
Copy linkTweet thisAlerts:
@funmediadesignauthorJun 22.2009 — (also note, a global, undefined ytplayer variable declaration is necessary)[/QUOTE]

I think the variable is declared in the google javascript api code for the player.

Thanks
Copy linkTweet thisAlerts:
@nachtegaal9999Nov 04.2009 — Hi,

I must say that your link is great and works fine. http://funmediadesign.com/tests/media

I have an issue for loading the data as duration and current time found on page

http://datingnl.comxa.com/ This is not a commercial site!!!

I want to use that data to close the window afterwards it has been ended.

Does sombody know how to get

Best regards

Simon, Netherlands, Hoorn
×

Success!

Help @funmediadesign spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...