Monday, July 9, 2012

[YouTube-API] Re: player.getDuration() and player.getPlayTime() seems to be broken when the video hasn't started playing

Hi Prem,

I'm having some weird behaviors with this as well. Using swfobject 2.2

My workaround was to change the problematic functions as follows:

function getDuration() {
    if('getDuration' in ytplayer) {
            return ytplayer.getDuration()
    }
}

So that the function ins't called when the player isn't really ready ( I also forced the HTML object initialization to fix a loading problem )

Hope it helps,

Regards,

Eduardo Chongkan
Likan Development

El miércoles, 2 de mayo de 2012 18:05:43 UTC-6, Prem Sichanugrist escribió:
Hi guys,

I'm using Youtube IFRAME API to embed a video into my site. I just found out a strange thing this evening that I'm not able to get anything return from `player.getCurrentTime()` or `player.getDuration()` unless the player has started. (It returned `undefined`.) The code I'm using were working just fine before 6pm EST, so I'm not sure if there's some change to it that breaks it or not.

The code snippet I used to test was something like this:

// Get called from YT.Player onReady event
function onPlayerReady(event) {
  console
.debug(event.target.getDuration(); // this returns undefined
}

Thank you,

Prem S.

--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To view this discussion on the web visit https://groups.google.com/d/msg/youtube-api-gdata/-/Thmy7m8dbaEJ.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.

No comments:

Post a Comment