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

metadata to javascript


Hi how can i get metadata sent to a javascript function, have found a couple of topics with similer question but none seem to answer this question. I am using the latest player version just downloaded today.



as a very simple test i copied some code from a different topic and made this:

function playerReady(obj){
alert(1);
player = gid(obj.id);
player.addModelListener('META', 'metaMonitor');
};

function metaMonitor(obj){
alert(2);
};

1 gets alerted but 2 does not

25 Community Answers

JW Player

User  
0 rated :

Hi there

Thank you for your answer, this does indeed make the js trigger when there is meta data.

however im not getting the complete data
just the info on the meta tag itself not the event inside it.

META Data:
type: cuepoint
parameters:
version: 4.5.230
client: FLASH WIN 10,0,2,54
name: 8sec
id: playerID
time: 8.120000000000001

inside this meta tag i added an event with the flash media encoder called URL with the setting http://www.google.com

im guessing that can be accessed via an object inside the above meta object?

Thank you

JW Player

User  
0 rated :

The code dumps all of the name:value pairs inside the meta object that is returned by the player.

The player may not be looking for other name:value pairs, so your URL:'http://www.google.com' pair may not be available.

JW Player

User  
0 rated :

hm ok, but thats a function inside the jw code right? so i could not change that....

JW Player

User  
0 rated :

I looked through the code I'm not a Flash expert by any means and it looks like the meta object is requested from a flash class, so it may not be very easy to change. On the other hand, if your name:value pair is in the meta tag, it should be retrieved by the player I think. You would have to ask the real Flash experts Jeroen & Zachary.

I'm kinda guessing that your data is not there, or it is invalid, and therefore ignored by Flash.

JW Player

User  
0 rated :

I was thinking very dangerous, I know one of the meta data objects pops up with a long list of objects. Maybe your object is one of them?

When I get back home, I'll take the objects apart and see what is in them.

JW Player

User  
0 rated :

Yeah, it's crazy...

There are several levels of metadata in some of the objects. Maybe you can find your URL in one of them?!?

*http://willswonders.myip.org:8074/Simple_ErrorAction.html*

JW Player

User  
0 rated :

how are you finding these layers though?

have copied your script over. and modified it a little:

function metaMonitor(obj){
var meta = '';
var metaDiv = document.getElementById('metaContent');


for(var j in obj){
metaDiv.innerHTML += j+ '='+obj[j]+'<br />';

if (obj[j] == 'metadata') {
document.getElementById('fileInfo').innerHTML +='Width: '+obj['width']+'px - Height: '+obj['height']+' - Duration: '+Math.round(Number(obj['duration']))+' sec. - Bitrate: '+obj['videodatarate'];
}

if(j == 'parameters'){
var metaextra = '';
for(var k in obj[j]){
metaextra += j+'-'+k+': ' + obj[j][k]+'<br />';
for(var l in obj[j][k]){
metaextra += j+'-'+k+'-'+l + ': ' + obj[j][k][l]+'<br />';
}
}

metaDiv.innerHTML += '<br />*METAEXTRA*<br /> ' + j + ' Data: ' + metaextra + '<br /><br />';

}
}

metaDiv.innerHTML += '<hr />';
};




My special meta tags are placed on 10 and 20 seconds and when they trigger i get the following data:

type=cuepoint
parameters=

METAEXTRA
parameters Data:

version=4.5.230
client=FLASH WIN 10,0,2,54
name=cue10
id=playerID
time=10.01



type=cuepoint
parameters=

METAEXTRA
parameters Data:

version=4.5.230
client=FLASH WIN 10,0,2,54
name=Cue Point
id=playerID
time=20.087


i cant see any more layers of objects in this. and the data retrieved with the loop from parameters seems to be empty?

JW Player

User  
0 rated :

To find the extra layers, I expanded anything that displayed:bc.. sampledescription: [object Object]
which is a indication that there is another object with a name:value pair.

Can you post a link to a video file that has Cue Points so I can test it?

JW Player

User  
0 rated :

yea i noticed your "trackinfo" and "sampledescription" tags in the code but they yielded no results for me.

i have placed the video im using here:
www.thomassmart.com/share/galactica2.flv

i used the flash media encoder cs4 to encode it by the way and made a cue point on 10 seconds called cue10 with a parameter called IMAGE with the value being an url to an image. on 20 seconds there is another cue point called Cue Point with a parameter called LINK and and the value being an url.

Thanks again.


edit: do you have a red5 streaming server by the way? if so could you see if that video works smoothly from your server? seems to be working terrible on mine. keeps freezing and loosing its buffer and seeking doesnt work at all...

JW Player

User  
0 rated :

OK, I'll check your video.

I have several Red5 servers, so I'll also check your video on them.

JW Player

User  
0 rated :

Your Cue Points are definitely in the metadata.

Here's a dump from flvdump:bc.. Magic:FLV
Version:1
Hasaudio:yes
Hasvideo:yes
Offset:9
---Tag#1at0xD(13)---
Tagtype:Meta
Bodylength:483
Timestamp:0
*Metadataeventname:onMetaData
*Metadatacontents:{
'duration'=>60.075000
'width'=>599.000000
'height'=>329.000000
'videodatarate'=>900.000000
'framerate'=>23.969986
'videocodecid'=>4.000000
'audiodatarate'=>128.000000
'audiodelay'=>0.027000
'audiocodecid'=>2.000000
'cuePoints'=>{
'0'=>{
'name'=>'cue10'
'time'=>10.010000
'type'=>'event'
'parameters'=>{
'LINK'=>'http://www.google.com'
}
}
'1'=>{
'name'=>'CuePoint'
'time'=>20.087000
'type'=>'event'
'parameters'=>{
'IMAGE'=>'http://www.troistudio.com/img/troi_logo_menu.gif'
}
}
}
'canSeekToEnd'=>true
}
Previoustagsize:494



The Cue Points showup when the player hits the time. See items 5 & 6 in the dump below.

I see what you're saying, *parameters* is coming back empty! I can't get it to give up anything, no matter how I try to do it. Explicitly as *obj[j][0]* or *obj[j]['LINK']* still comes back empty. So the rest of the *parameters* object isn't being returned by the Flash Player (I guess!?!).

The only unusual thing that I see, is that LINK is all uppercase. I wonder if this a quirk in the Adobe Flash Player, that it only returns metadata in lowercase or something like that, although cuePoints does have one uppercase letter. Can you try making link all lowercase and see what happens?

Here's a full dump of the metadata from playing the full video:bc.. 1. META Data:
client: FLASH WIN 9,0,124,0
canSeekToEnd: true
framerate: 23.969985961914062
type: metadata
duration: 60.075
videocodecid: 4
version: 4.6.248
width: 599
audiodelay: 0.027
id: playerID
height: 329
cuePoints: ,
videodatarate: 900
audiocodecid: 2
audiodatarate: 128

2. META Data:
client: FLASH WIN 9,0,124,0
liveXML:
type: xmp
id: playerID
version: 4.6.248

3. META Data:
client: FLASH WIN 9,0,124,0
version: 4.6.248
id: playerID
status: NetStream.Buffer.Full

4. META Data:
client: FLASH WIN 9,0,124,0
version: 4.6.248
bandwidth: 19453
id: playerID
bitrate: 971

5. META Data:
type: cuepoint
client: FLASH WIN 9,0,124,0
name: cue10
time: 10.01
id: playerID
parameters:
version: 4.6.248

6. META Data:
type: cuepoint
client: FLASH WIN 9,0,124,0
name: Cue Point
time: 20.087
id: playerID
parameters:
version: 4.6.248

7. META Data:
client: FLASH WIN 9,0,124,0
version: 4.6.248
id: playerID
status: NetStream.Buffer.Flush

8. META Data:
client: FLASH WIN 9,0,124,0
version: 4.6.248
id: playerID
status: NetStream.Buffer.Flush

9. META Data:
client: FLASH WIN 9,0,124,0
version: 4.6.248
id: playerID
status: NetStream.Buffer.Empty

10. META Data:
client: FLASH WIN 9,0,124,0
version: 4.6.248
id: playerID
status: NetStream.Play.Stop




Also, your video seems to work fine from Red5.

JW Player

User  
0 rated :

maybe its something with my red5 build... :/ its like my buffer stops receiving data it just dries up and dies. it only does that with my videos and not the videos that came with the oflademo.

have made a new video with the following cue points

cue5 - 5 seconds
test = hello world

cue10 - 10 seconds
foo = bar


i did a slightly different encoding this time to test with my red5, sorensen codec, 800 bitrate, keyframe every 15. (didnt help by the way, still the same buffer problems.)

www.thomassmart.com/share/galactica6.flv

cheers!

JW Player

User  
0 rated :

After trying everything that I can find on Google, I can't find a way to get the the cuePoint parameters. They simply aren't being passed, that I can find.

However, I did discover that a large XMP object is being passed and it has all of the metadata from the video, including the cuePoint parameters.

So, with a little bit of skullduggery, they are available.

See: *http://willswonders.myip.org:8074/Simple_ErrorAction.html*

You will have to store them in an array for later use as the cuePoints are hit in the video and that data is sent to the META Listener.

Not pretty, but it works.

JW Player

User  
0 rated :

very nicely done :D
i will play about with this some!


oh yea, gief function makeCoffee() ??

JW Player

User  
0 rated :

Hey Lost

i have a request. Im having real problems with buffering. its like the buffer just dries up and the video dies up and was wondering if you could help me with a bit of debugging?

would like to read my video into my player form one of your servers to see if its the player or my red5 server thats causing the issue...

let me know

JW Player

User  
0 rated :

Sure, if you shoot me an email at wellitsme AT gmail.com I'll give you the IP address of the red5 server.

Also, could you tell me exaclty how you created the Cue Points in your test files, because I'm finding that not all methods create the XMP object.

JW Player

User  
0 rated :

Hi all, I was looking at the "willswonders simple cue points demo the other day but it seems to have gone.

Is it somewhere else? I'd love to have a sticky beak at it.

I've trawled through as many of the posts on cue points as I can. Is it possible to link to an external file to fire the cue points as we've got a nifty way of generating an xml file directly out of ppt that we've used to link to another proprietary application that converts ppt to flash.

The purpose here is so that you don't have to manually insert lines of code for each cue point.

Any info would be appreciated.

By the way the post that directed to www.briefmeetings.com had a really good implementation of synch'd slides and video (although the video was quite buffery.

Cheers
Rob

JW Player

User  
0 rated :

Can any one View the Code here: for this Link:
http://willswonders.myip.org:8074/Simple_CuePoints.html
I can't reach the site.Said time out..
Thanks!

JW Player

User  
0 rated :

Yup - no problem for me.

JW Player

User  
0 rated :

@lost

if you are still interested, you can use RichFLV to import (xml) or manually add cue points.

You can also import xml files into adobe media encoder:

<?xml version='1.0' encoding='UTF-8' ?>
<FLVCoreCuePoints>

<CuePoint>
<Time>0120</Time>
<Type>event</Type>
<Name>fl.video.caption.2.0.subtitle1</Name>
<Parameters>
<Parameter>
<Name>text</Name>
<Value>english subtitle</Value>
</Parameter>
<Parameter>
<Name>text1</Name>
<Value>subtitulo en espanol</Value>
</Parameter>
<Parameter>
<Name>endTime</Name>
<Value>3.000</Value>
</Parameter>
</Parameters>
</CuePoint>

<CuePoint>
<Time>4120</Time>
<Type>event</Type>
<Name>fl.video.caption.2.0.subtitle2</Name>
<Parameters>
<Parameter>
<Name>text</Name>
<Value>english subtitle</Value>
</Parameter>
<Parameter>
<Name>text1</Name>
<Value>subtitulo en espanol</Value>
</Parameter>
<Parameter>
<Name>endTime</Name>
<Value>8.120</Value>
</Parameter>
</Parameters>
</CuePoint>

</FLVCoreCuePoints>

JW Player

User  
0 rated :


@munarriz,

Thanks for the info. I have RichFLV.

It turns out to be much more useful to manipulate the XML object with a PHP script. Then you can get the Cue Points and all of the other metadata immediately after the FLV or F4V file starts loading into the player.

JW Player

User  
0 rated :

Youcan'taddListenersimmediatelyafterplayerReady()iscalled.

Youmustwaituntiltheplaylisthasbeenloaded,indexedandisavailabletogetPlaylist().
bc.. varplayer=null;
varplaylist=null;


functionplayerReady(obj)
{
player=gid(obj.id);
alert('PlayerID:'+player.id)
addListeners();
};


functionaddListeners()
{
playlist=player.getPlaylist();

if(playlist!==null)&&(playlist.length>0))
{
player.addModelListener('META','metaMonitor');
}
else
{
alert('TryAgain!');
setTimeout("addListeners();",100);
}
};


functionmetaMonitor(obj)
{
varmeta='';

for(varjinobj)
{
meta+='\n'+j+':'+obj[j];
}
alert('METAData:'+meta);
};


functiongid(name)
{
returndocument.getElementById(name);
};



Youcanseeitfunctioningonthis*[i]TechnologyDemonstrationPage:[/i]*

*http://willswonders.myip.org:8074/Simple_ErrorAction.html*

JW Player

User  
0 rated :

Fully functional: *http://willswonders.myip.org:8074/Simple_CuePoints.html*

The code displays a couple of images on your cuepoints. Would be useful for a slideshow or whatever. Of course, you can also open windows, turn out the lights and make coffee with the correct JavaScript.

Since I didn't have access to the cuepoints (I have to learn how to write them into the video), I used a switch to load the images.

JW Player

User  
0 rated :

Hello I have a problem with the cuepoints, I have a .flv archive with cuepoints, and I'd like to use it into the jw player.

thanks
erzo

JW Player

User  
0 rated :

Hey how does one read metadata injected into non flash video (HTML5 http stream) ?
- injection -- http://jmacmullin.wordpress.com/2010/11/03/adding-meta-data-to-video-in-ios/

Can the JW-player handle this type of metadata? Can you provide a javascript example?

This question has received the maximum number of answers.