1
我正尝试使用mediaelement.js设置播放器。 我正在执行我自己的自定义播放列表 - 我只想要一个播放器,并且点击播放列表中不同的标题,它必须自动更改播放器的来源。MediaElement.js使用同一个播放器播放音频和视频
我用相当简单的代码实现了这一点。
这里的初始化:
var player = new MediaElementPlayer("#audioplayer",
{
//if the <video width> is not specified, this is the default
defaultVideoWidth: 480,
// if the <video height> is not specified, this is the default
defaultVideoHeight: 270,
// if set, overrides <video width>
videoWidth: -1,
// if set, overrides <video height>
videoHeight: -1,
// width of audio player
audioWidth: 960,
// height of audio player
audioHeight: 30,
// initial volume when the player starts
startVolume: 0.8,
// useful for <audio> player loops
loop: false,
// enables Flash and Silverlight to resize to content size
enableAutosize: true,
// the order of controls you want on the control bar (and other plugins below)
features: ['playpause','progress','current','duration','tracks','volume','fullscreen'],
// automatically selects a <track> element
startLanguage: '',
// a list of languages to auto-translate via Google
translations: [],
// a dropdownlist of automatic translations
translationSelector: false,
// key for tranlsations
googleApiKey: '' }
);
这是改变SRC,上点击播放列表中的一个元素的代码。
document.getElementById('audioplayer').src = url;
if(url.search('youtube')!=-1 || url.search('youtu.be')!=-1)
{
document.getElementById('audioplayer').pluginType="youtube";
$('#audioplayer').attr("type","video/youtube");
}
else
{
document.getElementById('audioplayer').pluginType="native";
$('#audioplayer').attr("type","audio/mp3");
}
player.load();
player.play();
问题是玩家不能同时播放视频和音频源。我试过改变所有参数,包括src,pluginType等。它只播放音频文件或视频文件。
任何人都可以帮助我吗?我猜它与初始化有关 - 如MediaElement,AudioElement或VideoElement等。
在此先感谢。