SAPUI5:使嵌入式视频在取消时停止

时间:2015-03-27 13:53:18

标签: javascript html video youtube sapui5

在SAPUI5应用程序中,我有一个对话框,该对话框是从页脚中的按钮打开的(参见对话框代码here)。 在这个对话框中(片段 - > Std3)我有一个像这样嵌入的YouTube视频:

 <html:iframe id="video1" height="350" 
    src="//www.youtube.com/embed/mYbn9Q6P0cU?enablejsapi=1" frameborder="0" allowfullscreen="true"></html:iframe>

我想要的是在单击关闭按钮时自动停止视频(onDialogCloseButton;片段来自控制器)。我有一个嵌入式视频的类似代码(即不在对话框中,明显在xml视图中),并且它工作正常 - 使用:this._pauseVideo1(); 请建议在这做什么。 THX!

    openDialog: function (sType) {
if (!this[sType]) {
  this[sType] = sap.ui.xmlfragment(
    "fragment." + sType + "Dialog",
    this // associate controller with the fragment
  );
  this.getView().addDependent(this[sType]); 
  }

this[sType].bindElement("/ProductCollection/0");
// toggle compact style
jQuery.sap.syncStyleClass("sapUiSizeCompact", this.getView(), this[sType]);
this[sType].open();
  },

onStd3DialogPress: function (oEvent) {
this.openDialog('Std3');
 },


  onDialogCloseButton: function (oEvent) {
  var sType = oEvent.getSource().data("dialogType");
  this[sType].close(); 
  this[sType]._pauseVideo1(); 

  },  
 _pauseVideo1: function() {
    var oVideoIFrameWindow = this.byId("video1").$()[0].contentWindow;
      oVideoIFrameWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
  },

0 个答案:

没有答案