Nuevo playlist javascript functions
Control the playlist programmatically
Playlist developed and designed by Nuevodevel.com features several public functions that allow you to manage playlist media items programmatically via javascript. You can navigate between media items (next or previous), start playback from the first index, or jump to the last. You can append a new media item to the end of the playlist, insert it before or after the existing item index, remove a playlist item, or even replace the existing playlist with a new one.
Playlist functions available to use
Variable name used to initialize video.js is "player" (can be any other name).Code snippet
player.playlist.next(); Play next itemplayer.playlist.previous(); Play previous itemplayer.playlist.first(); Play first itemplayer.playlist.last(); Play last itemplayer.playlist.currentItem(id); Play item by playlist idplayer.playlist.insert(mediaItem); Appen new media item to the end of the playlistplayer.playlist.insertBefore(mediaItem, id); Insert new media item before existing media item Idplayer.playlist.insertAfter(mediaItem, id); Insert new media item after existing media item Idplayer.playlist.remove(id); Remove playlist item by Idplayer.playlist.new(New_playlist); Load new playlist programmaticallyPlaylist media item definition
There are many ways to define playlist media. The minimum required information is the media source(s) url. However, you should also include the thumb image, media title, and duration at a minimum, e.g.Code snippet
var mediaItem = {src://www.domain.com/video.mp4, type:"video/mp4", thumb: //www.domain.com/thumb.jpg", title:"media title", duration: "03:20"}Code snippet
var mediaItem={sources:[{ src:"//www.domain.com/video_720.mp4",type:"video/mp4",label:"720p",res:"720"},{ src:"//www.domain.com/video_360.mp4",type:"video/mp4",label:"360p",res:"360",default:1},{ src:"//www.domain.com/video_240.mp4",type:"video/mp4",label:"240p",res:"240"}],thumb:"www.domain.com/thumb.jpg",,title:'media title',duration:"03:20" }var mediaItem = {
src://www.domain.com/video.m3u8, type:"application/x-mpegURL",
tracks:[
{ kind:"captions",src:"//domain.com/en.vtt",srclang:"en",label:"English" },
{ kind:"captions",src:"//domain.com/de.vtt",srclang:"de",label:"Deutsch" },
{ kind:"chapters",src:"//domain.com/chapters.vtt",srclang:"en" }
],
thumb: //www.domain.com/thumb.jpg",
title:"media title",
duration: "03:20",
poster: "//domain.com/poster.jpg",
metaDescription: "media description"
}
Code snippet
track:{ kind:"chapters",src:"//domain.com/chapters.vtt",srclang:"en" }Code snippet
player.uniquePlaylist="unique_id";player.playlist(my_playlist)