1
我是一个noob,仍然对某些事情感到困惑。Electron/AngularJS - 从showOpenDialog动态加载视频文件
我使用的是Angular 1.5.8和Electron,我试图在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="avc1.42E01E, mp4a.40.2"" src="{{videoPathFile}}" />
</video>
</div>
当我打开视频,在isVideoOpened设置为true和videoPathFile是正确的(如果我打开这个文件路径在单独的工作方式相同)。
但是,当我按下开始时文件不会开始缓冲。我究竟做错了什么?