2013-07-23 44 views
0

我需要將我的jwplayer放入一個對話框中,並且我是這樣創建其他對話框的,但它失敗了,出現錯誤「TypeError:jwplayer(...)。setup不是函數「將jwplayer嵌入到jQuery對話框中

這裏是我的代碼如下:

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

對不起,我才意識到我的錯誤。

我調用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;