这是一些示例代码,它们将执行以下操作:
<!DOCTYPE html>
<html>
<head>
<title>Add to Playlist</title>
<script type="text/javascript" src="http://www.longtailvideo.com/jwplayer/jwplayer.js"></script>
</head>
<body>
<div id="container"></div>
<script type="text/javascript">
jwplayer("container").setup({
height: 254,
width: 720,
file: "http://content.bitsontherun.com/videos/nPripu9l-60830.mp4",
image: "http://content.bitsontherun.com/thumbs/nPripu9l-320.jpg",
title: "Big Buck Bunny trailer",
listbar: {
position: "right",
size: 280,
},
primary: 'flash'
});
function addVideo(videoUrl, videoThumb, videoTitle) {
var playlist = jwplayer().getPlaylist();
var newItem = {
file: videoUrl,
image: videoThumb,
title: videoTitle
};
playlist.push(newItem);
jwplayer().load(playlist);
}
</script>
<p>Click on one of the links below to add an item to the player:</p>
<ul>
<li><a href="http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/16026/loading-a-playlist-into-the-player#" onclick="addVideo('http://content.bitsontherun.com/videos/yj1shGJB-60830.mp4', 'http://content.bitsontherun.com/thumbs/yj1shGJB-320.jpg', 'Sintel trailer'); return false;">Add the Sintel trailer to the playlist</a></li>
<li><a href="http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/16026/loading-a-playlist-into-the-player#" onclick="addVideo('http://content.bitsontherun.com/videos/i8oQD9zd-kNspJqnJ.mp4', 'http://content.bitsontherun.com/thumbs/i8oQD9zd-640.jpg', 'Tears of Steel'); return false;">Add the Tears of Steel trailer to the playlist</a></li>
</ul>
</body>
</html>