我需要把我的jwplayer放在一个Dialog中,我按照我创建其他对话框的方式来做,但它失败并出现错误“TypeError:jwplayer(...)。setup不是函数”
以下是我的代码:
function popupVideoPlayDialog(urlToRenderedVideo, thumbnailUrl, cvId) {
// create dialog frame div for dialog
var dialogFrame = document.createElement('div');
dialogFrame.setAttribute('id', 'videoPlayDialog');
// Load Videos
loadVideoByUrlWithSize( "videoPlayDialog", urlToRenderedVideo, thumbnailUrl, 640, 480);
$dialog = $(dialogFrame).dialog({
width : 640,
height : 480,
modal : true,
show : {
effect : 'clip',
duration : 500
},
hide : {
effect : 'clip',
duration : 500
},
title : 'video play',
buttons: [
{text: "Cancel", click: function() {$(this).dialog("close")}}
]
});
return false;
}
function loadVideoByUrlWithSize(elementId, videoUrl, videoThumbnail, width, height) {
jwplayer(elementId).setup({
file : videoUrl,
image : videoThumbnail,
width : width,
height : height
});
}
答案 0 :(得分:0)
抱歉,我刚刚意识到自己的错误。
我调用loadVideoByUrlWithSize加载视频的方式不正确,因为在创建或打开对话框之前不应该这样做。
这是我的解决方案,希望有所帮助:
$dialog = $(dialogFrame).dialog({
width : 640,
height : 480,
modal : true,
**open: function(){loadVideoByUrlWithSize( "videoPlayDialog", urlToRenderedVideo, thumbnailUrl, 640, 480);},**
show : {
effect : 'clip',
duration : 500
},
hide : {
effect : 'clip',
duration : 500
},
title : 'video play',
buttons: [
{text: "Cancel", click: function() {$(this).dialog("close")}}
]
});
return false;