我正在使用Ionic
開發應用程序,並且我允許用戶上傳視頻。因此,爲了播放視頻,我整合了Videogular
庫。視頻圖像:無法動態添加視頻
控制器代碼
$scope.videoAPI = null;
$scope.config = {
playsInline: false,
preload: "auto",
autoHide: false,
autoHideTime: 3000,
autoPlay: true,
sources: [],
theme: "lib/videogular-themes-default/videogular.css",
plugins: {
poster: "http://www.videogular.com/assets/images/videogular.png"
}
};
$scope.onPlayerReady = function(api) {
console.log('onPlayerReady : : ', api);
$scope.videoAPI = api;
}
$scope.uploadVideo = function() {
if (!deviceType) {
$('#fileSelect').val('').click();
} else {
console.info('Uploading Video..');
MediaService.browseVideo().then(function(uploadResponse) {
console.info('video uploadResponse : : ', uploadResponse);
var response = JSON.parse(uploadResponse.response);
var videoUrl = response.url.video[0].location;
//Here I'm Dyncamically setting the URL of my video
$scope.config.sources.push({
src: $sce.trustAsResourceUrl(videoUrl),
type: 'video/mp4'
});
console.info('Video Uploaded..');
}).catch(function(error) {
console.warn('Error while fetching video ', error);
$scope.showAlert('Video Upload', error);
});
}
};
在上傳視頻$scope.config.sources
正確更新。但是,當我檢查DOM我不明白的視頻there..Here是截圖
所以,我應該怎麼做才能使這項工作?
我正在使用'$ q'來解析諾言..並且我已經嘗試過'$ scope。$ apply()'它正在拋出錯誤'$ digest already already progress'。 – Ricky