Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Get playlist MediaID from GetState function


I want to set up something to keep track of users video views. The videos are set up in a playlist with a MediaID which happens to be the database VideoID.

bc.. <script type='text/javascript'>
function GetState(obj) {
curState = obj.newstate;
if(curState == "PLAYING"){
// Send video id to the database
}
}


jwplayer('mediaplayer').setup({
"flashplayer": "player.swf",
playlist: [{mediaid: 8,image: '/images/trainingcover.png',file: '/videos/test.mp4',title: 'Test Video'}],
"playlist.position": "bottom",
"playlist.size": 250,
"width": 670,
"height": 650,
"controlbar": {
"position": "bottom"
}
});
</script>



Whats the best way to do this?

3 Community Answers

Ethan Feldman

JW Player Support Agent  
0 rated :

have you tried to use console.log and alerts to see if you can pass anything in here?

JW Player

User  
1 rated :

I ended up getting it to work like this:

bc.. <script type='text/javascript'>
function GetState(obj) {
curState = obj.newstate;
if(curState == "PLAYING"){
// Send video id to the database
}
}
jwplayer('mediaplayer').setup({
"flashplayer": "player.swf",
playlist: [{mediaid: 8,image: '/images/trainingcover.png',file: '/videos/test.mp4',title: 'Test Video'}],
"playlist.position": "bottom",
"playlist.size": 250,
"width": 670,
"height": 650,
"controlbar": {
"position": "bottom"
},
events: {
onPlay: function(evt){
var playlistitem = this.getPlaylistItem();
console.log(playlistitem.mediaid)
}
}
,displaytitle: "false"
});
</script>

Ethan Feldman

JW Player Support Agent  
0 rated :

Nice, thanks for sharing.

This question has received the maximum number of answers.