Player.js: problems with "timeupdate"

Created on 8 Jul 2016  路  6Comments  路  Source: vimeo/player.js

Expected Behavior

Every other event seems to be working (although I haven't tested them all), for some reason I cannot get "timeupdate" to work.

player.on('timeupdate', function(data) {
//should see some activity here
});

Actual Behavior

player.on('timeupdate', function(data) {
//ignoring everything inside
});

Steps to Reproduce

See codepen below:
http://codepen.io/simpson77/pen/YXowmy

Most helpful comment

If you remove the ?api=1 query parameter, those events should work. We'll fix it eventually, but since we no longer recommend using api (or player_id), it's not high on the list.

All 6 comments

hey @simpson77, try to create a Player object instead of using an Iframe.

<div data-vimeo-id="129779425" data-vimeo-autoplay="true" id="player_1"></div>

If you remove the ?api=1 query parameter, those events should work. We'll fix it eventually, but since we no longer recommend using api (or player_id), it's not high on the list.

@ericksahara I went ahead and tried your method. I definitely like the cleaner code, however .on('timeupdate', function(data) {}); is still not firing for me.

http://codepen.io/simpson77/pen/YXowmy

@simpson77 there's nothing in your code setting the status variable, so it's throwing an error there.

@bdougherty - unbelievable. I'm so blind.

Is it possible to insert data from vimeoplayer to database that the player is "PLAYING" when it is playing mode and "PAUSED" when it is in paused mode and "COMPLETED" when it is ended.
I wrote a code like this

player.on('play',function (event) {

                        playerStart(this, videoID, '');

                    });
                    player.on('pause', function (event) {playerPaused(videoID); 

                    });                             
                    player.on('ended',function () { playerCompletedEvent(videoID); 

                    });

Tracking code in seperate file

var PlayerObjs = {};
var arrays_created = 0;
var TimersForPLayer = {};
var CompletedPlayers = {};
var trackingIDs = {};
var strids = "0";
function playerStart(player, videoID, hdnvarID) {
if (strids.indexOf(videoID) < 0) {
TimersForPLayer[videoID] = 0;
CompletedPlayers[videoID] = 0;
trackingIDs[videoID] = 0;
if (strids == "0")
{
strids = videoID;
}else{
strids = strids + "," + videoID;
}
}

if (TimersForPLayer[videoID] == 0) {
if ($(PlayerObjs[videoID]).length > 0) {
TimersForPLayer[videoID] = 1;
window.setInterval("trapCode(" + videoID + ",'" + hdnvarID + "')", (videoUpdateDuration1000));
}
else {
PlayerObjs[videoID] = player;
TimersForPLayer[videoID] = 1;
window.setInterval("trapCode(" + videoID + ",'" + hdnvarID + "')", (videoUpdateDuration
1000));
}
}
}
function trapCode(videoID, trackerid) {
if (CompletedPlayers[videoID] == 0) {
sendAjaxCall(videoID);
if (trackerid != "") {
if ($('#' + trackerid).length > 0) {
$('#' + trackerid).val(trackingIDs[videoID]);
}
}
}
}
function playerCompletedEvent(videoID) {
CompletedPlayers[videoID] = 1;
sendAjaxCall(videoID);
}
function playerPaused(videoID) {
sendAjaxCall(videoID);
}
function sendAjaxCall(videoID) {
try {
$.post("Tracking.aspx",
{ 'MemberID': sessionMemberId,
'ProspectID': sessionProspectId,
'VideoID': videoID,
'WebSiteID': sessionWebSiteId,
'WatchVideoID': trackingIDs[videoID],
'IsVideoManager': false,
'ReturnedFromAsp': false,
'PlayTime': parseInt(PlayerObjs[videoID].getPosition()),
'PlayerStatus': PlayerObjs[videoID].getState(),
'BrowserAgentName': browserName,
"t=": Math.random()
},
function (data) {
if (trackingIDs[videoID] == 0) {
trackingIDs[videoID] = data;
}
}
);
}
catch (ex) {
}
}

This code should send an Ajax call to the 'Tracking.aspx' file. By using 'Tracking.aspx.cs' file i have to insert status into database.
The vimeoplayer is having event like " event = Object {seconds: 30.05, percent: 0.135, duration: 222.99}"
I want an event like "event = Object {oldstate: "PAUSED", newstate: "PLAYING"}" to insert into my database.
Is the vimeoplayer support event objects like state?

Was this page helpful?
0 / 5 - 0 ratings