问题
I need to put my jwplayer inside of a Dialog, and I did it as how I created other dialogs, but it failed with error "TypeError: jwplayer(...).setup is not a function"
Here is my code as follow:
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
});
}
回答1:
Sorry, I just realized my mistake.
The way I call loadVideoByUrlWithSize to load video is not correct, since this should not be done before the dialog created or opened.
Here is my solution, hope it helps:
$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;
来源:https://stackoverflow.com/questions/17804992/embedded-jwplayer-into-jquery-dialog