-
-
Save joshuarrrr/65a7bac5ef02307c96ee6ccd16540968 to your computer and use it in GitHub Desktop.
An example script demonstrating how to track custom video players with Parse.ly's JavaScript API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var platform = "myVideoPlatform"; | |
var strategy = { | |
platform: platform, | |
searchTags: ["DIV"], | |
verify: function(elem) { | |
return (' ' + elem.className + ' ').indexOf(" my_video ") !== -1; | |
}, | |
subscribe: function(elem) { | |
var playerApi = myVideoJsApi(elem); | |
playerApi.on("play", function(playedVideoMetadata) { | |
// this hypothetical player API calls its event handlers with | |
// the metadata of the video as the only argument. with a different | |
// player API, you might need to perform some more metadata lookups, | |
// possibly from disparate data sources. | |
PARSELY.video.onPlay(playerApi, playedVideoMetadata.id, { | |
duration: playedVideoMetadata.duration, | |
image_url: playedVideoMetadata.image_url, | |
pub_date_tmsp: playedVideoMetadata.pub_date_tmsp, | |
title: playedVideoMetadata.title, | |
author: playedVideoMetadata.author, | |
tags: playedVideoMetadata.tags, | |
video_platform: platform | |
}); | |
}); | |
playerApi.on("pause", function(pausedVideoMetadata) { | |
PARSELY.video.onPause(playerApi, pausedVideoMetadata.id); | |
}); | |
console.log("Subscribed to custom embed with ID '" + elem.id + "'"); | |
} | |
}; | |
PARSELY = window.PARSELY || {}; | |
PARSELY.onload = function() { | |
PARSELY.video.addStrategy(strategy); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment