I had angular directive that appended video element
into html something like this
elem.append("<video " + "src='" + scope.MediaURL + "' type='video/" + type + "'"></video>")
I have now moved to use templateUrl
and there I have video element like this:
<video controls preload="metadata" autoplay ng-src="{{mediaUrl | trustUrl}}"></video>
trustUrl
is filter I took from here because of the same problem.
But the problem is that now the video is downloaded twice. And I can't figure out why. Could it because of the filter?
EDIT: I don't think it's because of the filter, because without it, the error is thrown twice.
EDIT2: I need to provide more details. The template has both video
and img
elements. Only one is shown depending on what type of media is in mediaUrl
. So it looks like this:
<video ng-if="mediaType == 'video'"></video>
<img ng-if="mediaType == 'image'" />
The video is downloaded twice only the first time video
element is shown. So if the mediaType
is image and is changed to video, it will be downloaded twice. If I then change url which also has video, it will be downloaded once. If I change url back to image and then back to video, it will be downloaded twice again and so on.