Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

Trying to 'get' playlistItem

8 replies [Last post]

Basically I want to be able to control a menu through JS by highlighting the current video.

But I need to be able to get the value of the current playlist item.

I have looked at the API/js pages and tried looking around the site/google searchs and can't seem to figure this out.

The only thing I've seen that comes close to this is a player command: playlistItem(i:Number)
I havn't been able to get anywhere with it but it seems like that tells the player to play that list item.

How can I get the current number in list? (I'm using an XML file for a playlist).

Thanks,
Justin

Sorry, I should of posted the code I have:

JS:

var currentState = "NONE";
var player = null;
function playerReady(thePlayer) {
player = document.getElementById(thePlayer.id);
addListeners();
}

function addListeners() {
if (player) {
player.addModelListener("STATE", "stateListener");
} else {
setTimeout("addListeners()",100);
}
}
    function stateListener(obj) { //IDLE, BUFFERING, PLAYING, PAUSED, COMPLETED
currentState = obj.newstate;
//when something finishes------------------
if ((currentState == "COMPLETED")) {
alert(currentItem);
}
}

function createPlayer() {
var flashvars = {
file:"playlist.xml",
repeat:"list",
autostart:"true"
}
var params = {
allowfullscreen:"true",
allowscriptaccess:"always"
}
var attributes = {
id:"player1", 
name:"player1"
}
swfobject.embedSWF("player.swf", "jwplayer", "720", "480", "9", false, flashvars, params, attributes);
//swfobject.js = swfobject 2.2 (version)
}

http://developer.longtailvideo.com/trac/wiki/Player4Events#Controllerevents

The currently playing item is always available through the item flashvar.

How could I read that using JS? I've never experimented with that type of thing before.

Thanks,
Justin

I tried adding this to the if statement (COMPLETED)

var theNumber = player.playlist.currentItem();

But got nothing :(

player.getConfig()['item']

Sigh, sorry.

Where should I put that? I've tried a number of things

function stateListener(obj) { //IDLE, BUFFERING, PLAYING, PAUSED, COMPLETED
currentState = obj.newstate;
currentItem = obj.getConfig()['item'];
//when something finishes------------------
if ((currentState == "COMPLETED")) {
alert(currentItem);
//alert(player.getConfig()['item']);
//currentItem = player.getConfig()['item'];
}
}

Is there a place with more documentation? I'm not finding anything I need for the stuff I try to do :/

function stateListener(obj)
{
  if(obj.newstate == "COMPLETED")
  {
    alert('Current Item: ' + player.getConfig()['item']);
  }
}

Interesting...now it works?
That was seriously the first thing I tried.

Thank you for your help,
Justin