[英]Angular media player and dynamic content
I have method in my controller which get audio: 我的控制器中有获取音频的方法:
$scope.searchTracks = function(text) {
Search.search.get({
text: text
}, function(data) {
$scope.tracks = data;
$sce.trustAsResourceUrl($scope.tracks.Mp3Ref);
})
}
For playing i use this player: http://mrgamer.github.io/angular-media-player/ 要玩游戏,请使用以下播放器: http : //mrgamer.github.io/angular-media-player/
In template: 在模板中:
<div class="song_block" ng-repeat="track in tracks">
...
<audio media-player="trackPlayer" ng-src="[[ track.Mp3Ref ]]" ></audio>
<span ng-click="trackPlayer.playPause();" ng-class="{ 'pauseZ': trackPlayer.playing, 'playZ': !trackPlayer.playing} "></span>
</div>
Also, I have a search bar that updates the tracks. 另外,我有一个搜索栏,可以更新曲目。 So, when I go to the site and click "Play" audio output.
因此,当我转到站点并单击“播放”音频输出时。 when I type something in the search and get new tracks - it does not work.
当我在搜索中输入内容并获取新曲目时-它不起作用。 how come?
怎么会? src in the right path, in the console errors do not get
src在正确的路径中,在控制台中不会出现错误
As answered privately angular-media-player
is built natively around playlists, and is not designed to have many directives in one page (events collide as they are name-based and bad stuff happens). 正如私下回答的那样,
angular-media-player
本身是围绕播放列表构建的,并且其设计目的不是在一页中包含很多指令(事件会碰撞,因为它们基于名称并且会发生不良情况)。
Most straightforward approach is build a playlist comprising all the songs in your page, then just use ng-click="mediaPlayer.playPause($index)"
inside the ng-repeat
loop. 最直接的方法是建立一个包含页面中所有歌曲的播放列表,然后在
ng-repeat
循环内使用ng-click="mediaPlayer.playPause($index)"
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.