我不知道该怎么称呼这个问题,所以如果你想让我以后编辑它,请随时发表评论。
作为开发人员,我在历史上遇到了最烦人和最奇怪的错误。我会尽力解释它,但如果你们需要更多信息,请告诉我并添加更多信息。
案例:
我的应用程序正在使用Angular
框架。现在,我的客户可以将视频上传到页面(以及其他资源),然后以幻灯片形式播放。
每张幻灯片都是一个元素,可以是以下项目之一:
现在我尝试创建一个包含12个不同视频的视频。
幻灯片由以下html组成:
<lb-video ng-show="component.component_type_id == 1" resource-token="{{components[i].video_mp4_path}}" media-type="components[i].content_type"></lb-video>
<view-sound ng-if="component.component_type_id == 2" ng-controller="SoundController"></view-sound>
<view-doc ng-if="component.component_type_id == 4" ng-controller="DocumentController"></view-doc>
<view-text ng-if="component.component_type_id == 5" ng-controller="TextController"></view-text>
现在lb-video
指令如下所示:
LB-视频:
<div ng-show="dd.isDesktop()">
<div class="lbVideo inline center-block">
<video id="player1" src="{{videoPath}}" controls="controls" width="598" height="320">
</video>
</div>
</div>
<div ng-show="!dd.isDesktop()">
<div ng-if="dd.isTablet() && videoPath != null">
<video width="459" height="320" controls>
<source src="{{videoPath}}" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
<div ng-if="!dd.isTablet() && videoPath != null">
<video width="250" height="220" controls>
<source src="{{videoPath}}" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
</div>
使用以下link function
:
link: function (scope, element, attr) {
function init() {
scope.srcUrl = null;
scope.videoPath = null;
$http.get(LRM.getDeviceResource(scope.resourceToken))
.success(function (response) {
scope.srcUrl = response.data;
}).error(function () {
$http.get(api.getUrl('fileDecryption', scope.resourceToken)).success(function (response) {
scope.srcUrl = response;
})
});
scope.onPlayerReady = function (API) {
scope.API = API;
};
scope.dd = deviceDetector;
scope.LRM = LRM;
if (scope.mediaType == null) {
scope.mediaType = 'video/mp4'; // Fall back function attempts to load it as mp4
}
if (scope.resourceToken.match(/user_resources/)) {
setVideo(scope.resourceToken);
} else {
$http.get(LRM.getDirectPath(scope.resourceToken))
.success(function (response) {
setVideo(response);
}).error(function () {
$http.get(api.getUrl('fileDecryption', scope.resourceToken)).success(function (response) {
setVideo(response);
})
});
}
}
scope.$watch('resourceToken', function (newValue, oldValue) {
if (newValue) {
init();
}
}, true);
function setVideo(path) {
scope.videoPath = $sce.trustAsResourceUrl(path);
}
}
运行前6个视频没问题。它显示正常,视频播放。
然而无论我尝试第7段视频多少次(并从那里开始)都会出现这样的情况:
黑屏无事可做,无需显示。在这种情况发生之后,我以前的所有视频(我已经看过)都会这样做,我将无法播放视频,直到我重新加载页面。但是,如果我右键单击该元素并按(在新标签中打开视频)
它完美无缺:
这对我来说是一个非常大的问题,因为我的应用依赖于上传x个视频的人并将其播放给他们的客户。有谁知道为什么会发生这种情况?