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 등의 초기화와 관련이 있다고 생각합니다.
미리 감사드립니다.