jwplayer 将文件附加到播放列表

标签 jwplayer playlists

查看 jwplayer 的文档,我找不到任何有关如何将文件附加到现有播放列表的引用。

该规范允许用户在浏览网站时将媒体文件添加到播放列表,而不会中断当前文件的播放

player.getPlaylist().push({file:'test.mp3', 'title':"test"}) 不起作用(不希望它真正基于方法的名称),唯一的方法似乎是重新加载播放列表,如下所述:How to load playlist without restart the current playing video

但感觉不对,并且可能会妨碍无缝媒体添加。

另一个选择是编写一些自定义播放列表逻辑,但我宁愿避免这种情况并使用 jwplayers 自己的播放列表控件

有没有人有更好的方法来做到这一点? 感谢您的帮助!

最佳答案

这里是一些示例代码,将执行以下操作:

<!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>

关于jwplayer 将文件附加到播放列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17220793/

相关文章:

amazon-web-services - 使用 AWS Elastic Transcoder 和 S3 在不公开所有内容的情况下流式传输 HLSv4?

javascript - YouTube html5 播放列表在 IE9 中不起作用

android - 更新 Poweramp 播放列表

javascript - Spotify 应用程序播放列表,事件未触发

JW Player 的 javascript flashvar 问题

mysql - 在 JW Player 中添加/删除播放列表项(使用 MySQ/RTMP)

javascript - 如何隐藏JWPlayer 6 播放按钮?

audio - 确定声学相似性的方法(但不是指纹)

ios - google-api-objectivec-client youtube播放列表供稿没有关键字

javascript - jwplayer onTime() 每秒调用 setInterval() 几次