Embedded jwplayer into jQuery Dialog

守給你的承諾、 提交于 2019-12-13 04:27:58

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!