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

Start a playlist automatically


Hi All,
I'm trying to start a playlist automatically on load with a dynamic (PHP generated Playlist). Here is my script :

<script type="text/javascript">
var playerInstance = jwplayer("myElement");
playerInstance.setup({
playlist: [
<?php
foreach ($playlist_details as $key => $video_array) {
//$video_array = $this->common_model->select_record('videos', 'id', $video_id);
//dump_exit($key);
if ($last_array_item == $video_array['id']) {
?>
{
file: '../../uploads/videos/<?php echo $video_array['video_file'];?>',
image: "",
width: "100%",
aspectratio: "16:9",
autostart: true,
title: '<?php echo addslashes($video_array['video_title']);?>',
description: '<?php echo addslashes($video_array['video_description']);?>',
mediaid: '<?php echo $video_array['id'];?>'
}
<?php
}
else {
?>
{
file: '../../uploads/videos/<?php echo $video_array['video_file'];?>',
image: "",
width: "100%",
aspectratio: "16:9",
autostart: true,
title: '<?php echo addslashes($video_array['video_title']);?>',
description: '<?php echo addslashes($video_array['video_description']);?>',
mediaid: '<?php echo $video_array['id'];?>'
},
<?php
}
}
?>

]
});
</script>

As you can see 'autostart: true' is not working in this case... Is there a way to start the videos playing on page load and then shuffle (repeat from beginning)?
Any suggestion is highly appreciated!

2 Community Answers

Todd

JW Player Support Agent  
1 rated :

The autostart: ‘true’ parameter cannot be in the individual playlist items block, it needs to go in the root level of your player setup:

jwplayer().setup({
height: ‘360’,
width: ‘640’,
autostart: ‘true’,
playlist: [{
file: ‘’,
image: ’’
},{
file: ‘’,
image: ’’
},{
file: ‘’,
image: ’’
}]
})

dujmovicv N/A

User  
0 rated :

Well, I guess my mistake was I expected a more complicated solution. But the best solution is always the simplest one.
Thanks so much!

This question has received the maximum number of answers.