Link to home
Create AccountLog in
Avatar of Danzigger
Danzigger

asked on

Dynamically generate json-style array

Hi, I'm using Flowplayer and I need to use javascript to load a new video into an existing Flowplayer instance using clips loaded from ajax.
Like this...:
api.load([
{ mpegurl: '/my/other/video.m3u8' },
{ webm: '/my/other/video.webm' },
{ mp4: '/my/other/video.mp4' },
{ ogg: '/my/other/video.ogv' }
]);

...but I need to add the individual clips based on what the ajax returns. eg. There might be an mp4, webm and ogg version or there might be only mp4.

Can you tell me what the syntax would be for generating this dynamically and then calling something like api.load( myArrayOfClips );

The ajax returns an array of objects like:
clips[0].format (eg. "mp4")
clips[0].filename (eg. "theclip.mp4")

Thanks!
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Please post the url  you have and all the details like where is the data? A static list on the page or from an ajax call on another source.
Avatar of Danzigger
Danzigger

ASKER

The data is coming from an ajax call.  I'm not sure if you're asking for a url to see this in action (which isn't available) or the url of a clip?
ASKER CERTIFIED SOLUTION
Avatar of Danzigger
Danzigger

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Resolved it myself after some poking around.