angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

Video doesn't start muted inside an ng-repeat only in Firefox

Open sirio13 opened this issue 12 years ago • 9 comments

I have a video tag in an ng-repeat loop, and I want to start the video muted; however, it does't in Firefox v29.0.1. It works well in Chrome.

The code is very simple:

<div ng-app="myApp" ng-controller="myController">
 <div ng-repeat="number in numbers">
  <video src="http://techslides.com/demos/sample-videos/small.mp4" autoplay controls loop muted>
  </video>
  {{number}} Video</div>
</div>

I have put up a fiddle here: http://jsfiddle.net/YW6hP/7/

Reproducable: always Browsers: Firefox 29.0.1 Steps to reproduce: just open the Fiddle in Firefox and the video is not muted; and then in Chrome and the video is muted.

sirio13 avatar May 15 '14 09:05 sirio13

Hi, Thanks for reporting this issue. It looks like this is not an issue with Angular, but an issue with Firefox on how it handles dynamically added <video> elements

https://groups.google.com/forum/#!topic/discuss-webrtc/sTtGlsX8-0M http://stackoverflow.com/questions/14111917/html5-video-muted-but-stilly-playing

I would recommend that you write a polyfill directive that does the right thing for Firefox. I do not see this polyfill being part of angular core, so I will leave it open for a few more days in case a core member wants to jump in

lgalfaso avatar May 15 '14 15:05 lgalfaso

Hi, thank you for the attention! :-) At last I resolved with this directive I put in my video tags (I think is something like what you also suggested):

.directive('myVideo', function () {
    return {
      restrict: 'A',
      scope: {},
      link: function(scope, element, attrs) {
                element[0].muted = true;
       }
    };
})

Hope this may help others!

sirio13 avatar May 15 '14 17:05 sirio13

Glad you've sorted this one out @sirio13 !

pkozlowski-opensource avatar May 15 '14 17:05 pkozlowski-opensource

This now happens on the latest chrome.

jcampbell05 avatar Feb 24 '18 17:02 jcampbell05

Which version of Chrome do you mean? I can't reproduce it via the given Fiddle (http://jsfiddle.net/YW6hP/7/) on Chrome 64.0.3282.167 (Official Build) (64-bit)

petebacondarwin avatar Feb 24 '18 17:02 petebacondarwin

Chrome 64.0.3282.167 Official Build OS X 10.12 64 Bit

jcampbell05 avatar Feb 24 '18 22:02 jcampbell05

I am on OS X 10.13 but it seems strange that the behaviour would change for the same version of Chrome.

petebacondarwin avatar Feb 25 '18 09:02 petebacondarwin

I'm afraid as per the previous report, the best option for you would be to use the workaround here https://github.com/angular/angular.js/issues/7474#issuecomment-43242316

petebacondarwin avatar Feb 25 '18 09:02 petebacondarwin

Will use workaround for now

jcampbell05 avatar Feb 25 '18 17:02 jcampbell05