This is I would like to achieve. Post multiple youtube ids in wordpress post, something like this "3jSDiJ, DJIJWk, JDIJAs" and I would like to load them into to jw player and play them sequentially.
first I need to able to detect how many ',' are there so that in jw player code i can create a loop to create multiple of
{
'file': 'http://www.youtube.com/v?3jSDiJ',
}
this is an example of two videos
<script type="text/javascript">
jwplayer("container").setup({
'flashplayer': 'jwplayer.swf',
'playlist': [{
'file': 'http://www.youtube.com/v?3jSDiJ',
},{
'file': 'http://www.youtube.cmo/v?3jSDiJ',
}],
repeat: 'list'
});
</script>
your suggestion and help are appreciated
You haven't really given enough info to tell for sure, but assuming that the Youtube IDs are being stored in an array, you could do something like this -
$youtubeids=array('3jSDiJ', 'DJIJWk', 'JDIJAs');
foreach ($youtubeids as $youtubeid) {
echo "'file': 'http://www.youtube.cmo/v?".$youtubeid.",";
}
Just put this code so that it prints the output within your javascript.