1

I have this simple audio for mediaElement.js which works with normal HTML/Js but does not work with angularjs. The Media player is shown just fine but clicking play button does not work.

<div class="col-md-6">
    <div class="alert alert" ng-repeat="media in medias">
        <h3>{{media.title}}</h3>
        <p>{{media.summary}}</p>
        <audio id="{{media.filename}}" src="http://danosongs.com/music/danosongs.com-orb-of-envisage.mp3" type="audio/mp3" controls="controls">     
    </div>

</div>

<script>
    // using jQuery
    $('video,audio').mediaelementplayer(/* Options */);
</script>

![enter image description here][1]

Stefano Mtangoo
  • 6,017
  • 6
  • 47
  • 93

1 Answers1

0

I found the problem thanks to @Biswanath. I was loading Mediaelement before Angular finished loading the elements. So I had to call it when all elements are loaded. Googling I found the solution here and here is my HTML codes

<div class="alert alert" ng-repeat="media in medias" ng-init="$last ? loadMediaElement() : false">

Then in my controller scope, I register Javascript function which bootstraps MediaElementjs, since ng-repeat is done

    $scope.loadMediaElement = function()
    {
        $('video,audio').mediaelementplayer(/* Options */);
    };
Community
  • 1
  • 1
Stefano Mtangoo
  • 6,017
  • 6
  • 47
  • 93