Bruno Brito
Bruno Brito

Reputation: 365

Show videos in tag <video> with angularjs

View:

<div class="list card" ng-repeat="x in content.spells">
....
    <video width="320" height="240" ng-src="{{(getIdVideo(content.id) | trusted )}}"   controls>
          Seu navegador não suporta o elemento <code>video</code>.
    </video>
....
</div>

Controller:

$scope.getIdVideo = function(videoId){
    videoId = videoId.toString();
    for (var i=0; i<=4; i++){
      if (videoId.length != 4){
        //videoId = videoId.push('0');
        videoId = "0"+videoId;
      }

    }

    return 'http://cdn.leagueoflegends.com/champion-abilities/videos/mp4/'+videoId+'_02.mp4';
  };

The same video is shown 4 times. The same video is shown 4 times

I call this function getIdVideo() that returns a video according with the id. The way i do shows tha same video 4 times. The problem is that i need to show 4 videos to each id just changing, from 02 to 05, the number after "_" in url:

http:/cdn.leagueoflegends.com/champion-abilities/videos/mp4/'+videoId+'_02.mp4

How can i do that?

Upvotes: 1

Views: 1274

Answers (1)

Naga Sandeep
Naga Sandeep

Reputation: 1431

By the looks of it, id seems to be on content. But you need to set id on content.spells.

Then you can use

    <video width="320" height="240" ng-src="{{(getIdVideo(x.id) | trusted )}}"   controls>

Upvotes: 1

Related Questions