2016-11-22 18 views
1

私はまだノーベルであり、何かについてはまだ混乱しています。Electron/AngularJS - showOpenDialogからビデオファイルを動的に読み込みます。

ElectronでAngular 1.5.8を使用していますが、main.jsでdialog.showOpenDialogファイルが選択されているときにビデオローダーを開始しようとしています。

main.js

click(item, focusedWindow) { 
    dialog.showOpenDialog(
    win, { 
     filters: [{ 
     name: 'Video files', 
     extensions: ['mkv', 'avi', 'mp4'] 
     }], 
     properties: ['openFile'] 
    }, (fileNames) => { 
     if (fileNames === undefined) return; 
     var videoFilePath = fileNames[0]; 
     win.webContents.send('videoFilePath', videoFilePath); 
    } 
); 
} 

videoCtrl.js

const electron = require('electron') 
const ipcRenderer = electron.ipcRenderer 
var app = angular.module('videoModule', []); 

app.controller('videoCtrl', function($scope) { 

    $scope.isVideoOpened = false; 

    ipcRenderer.on('videoFilePath', function(event, arg) { 
    $scope.videoPathFile = arg; 
    $scope.isVideoOpened = true; 
    }); 

}); 

HTML

<div ng-controller="videoCtrl" ng-show="isVideoOpened"> 
    Here {{isVideoOpened}} Here2{{videoPathFile}} 
    <video id="v1" controls tabindex="0" autobuffer> 
    <source type="video/mp4; codecs=&quot;avc1.42E01E, mp4a.40.2&quot;" src="{{videoPathFile}}" /> 
    </video> 
</div> 

私はビデオを開くと、isVideoOpenedがtrueに設定されていると私はこれを開くとvideoPathFileは(正しいですファイルパスは別の方法で同じ方法で動作します)。

ただし、[スタート]を押し​​てもファイルはバッファリングを開始しません。私は間違って何をしていますか?

答えて

0

ng-showの代わりにng-ifを使用して解決しました。

でも、そのような詳細はhereと表示されます。

基本的にng-ifはサブスコープを生成するので、内側のタグに配置する必要があり、またng-srcを使用する必要があります。

<div ng-controller="videoCtrl" > 
    <div ng-if="isVideoOpened"> 
     <video id="v1" controls class="videoInsert"> 
      <source type="video/mp4; codecs=&quot;avc1.42E01E, mp4a.40.2&quot;" ng-src="{{videoPathFile}}" /> 
     </video> 
    </div> 
</div> 
関連する問題