Try CumulusClips Cloud Hosting

[SOLVED]Auto play Playlists Playlists now AutoPlay, and re-start after the last Video!

After about 3 hours of trying to blindly figure out how to do it, here it is, a super simple 7 Line fix...

Place this code after the <?php foreach ($playlistVideos as $playlistVideo): line in watch.phtml or play.phtml (depending on software version, has not been tested with the moble site yet):


if ($playlistVideo->videoId == $video->videoId):
$nextvid = current($playlistVideos);
endif;


Place this code anywhere, but I place it just after the endif statement that closes the loop:

<script>
document.getElementById('myVideo').addEventListener('ended',function(){
window.location.href = '<?=$videoService->getUrl($nextvid)?>/?playlist=<?=$playlist->playlistId?>';
},false);
</script>

Comments

  • I forgot to mention, add an id=myVideo section to the tag... oops.
  • ... grrr. lets try again. Change <video class="video-js vjs-default-skin" to <video id="myVideo" class="video-js vjs-default-skin"

    That will allow the javascript to grab the proper tag to determine when the video ended.
    You can eaily
This discussion has been closed.