Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 Video is not working with AngularJS ng-src tag

AngularJS ng-src doesn't work with HTML5 Video element in this fiddle: http://jsfiddle.net/FsHah/5/

Looking at video element, the src tag is being populated with the correct src uri, but the video doesn't play.

Is this not supported in AngularJS, what is the workaround for this?

like image 587
qais Avatar asked Mar 31 '13 10:03

qais


2 Answers

Just Create a Filter:

app.filter("trustUrl", ['$sce', function ($sce) {
        return function (recordingUrl) {
            return $sce.trustAsResourceUrl(recordingUrl);
        };
    }]);

In View File:

<audio src="{{Your_URL | trustUrl}}" audioplayer controls></audio>
like image 135
Sdd Sdei Avatar answered Nov 16 '22 17:11

Sdd Sdei


To play the video I just used the following method have a button called play and in the ng-click of the button you have to write this

 var myVideo = document.getElementsByTagName('video')[0];
myVideo.src = vidURL;
myVideo.load();
myVideo.play();

to play video in ng-repeat use index. hope it helps.

like image 8
kavinhuh Avatar answered Nov 16 '22 18:11

kavinhuh