continue to play next after playing all songs in shuffle list, add playlist to song list (#120)

* continue to play next after playing all songs in shuffle list

* add playlist to song list

* dedupe song list after adding
This commit is contained in:
sunjie21 2018-02-15 09:55:08 +08:00 committed by Listen 1
parent 149c669176
commit 6c3d1b55b9
4 changed files with 42 additions and 19 deletions

View File

@ -37,7 +37,7 @@ a {
text-align: left;
border-bottom: 1px solid;
margin-bottom: 20px;
}
}
.dialog-header .dialog-close {
float: right;
@ -53,7 +53,7 @@ a {
background-color: #333;
}
/*.masthead {
/*.masthead {
z-index: 999;
}*/
@ -91,7 +91,7 @@ a {
margin-top: 90px;
}
.site-wrapper {
.site-wrapper {
width:100%;
overflow:hidden;
position: absolute;
@ -271,11 +271,11 @@ a {
.m-playbar .btns .play{
width: 36px;
height: 36px;
margin-top:0;
margin-top:0;
background-position: 0px 0px;
}
.m-playbar .btns .play:hover{
.m-playbar .btns .play:hover{
background-position: 0px -36px;
}
@ -283,7 +283,7 @@ a {
background-position: -108px 0px;
}
.m-playbar .btns .pas:hover{
.m-playbar .btns .pas:hover{
background-position: -108px -36px;
}
@ -379,7 +379,7 @@ a {
.m-pbar {
position: relative;
}
.m-pbar.play {
@ -628,6 +628,13 @@ li {
top: 9px;
}
.menu .add-all {
display: inline-block;
position: absolute;
left: 175px;
top: 9px;
}
.menu .close-popup {
float:right;
margin-right: 14px;
@ -880,7 +887,7 @@ li {
}
.detail-songlist .detail-artist a{
color: #777777;
color: #777777;
}
.detail-songlist .odd {

View File

@ -76,7 +76,22 @@ var add_myplaylist = function(playlist_id, track) {
if (playlist == null) {
return;
}
playlist.tracks.push(track);
if (Array.isArray(track)) {
playlist.tracks = playlist.tracks.concat(track);
} else {
playlist.tracks.push(track);
}
// dedupe
var newTracks = [], trackIds = [];
playlist.tracks.forEach(function (track) {
if (trackIds.indexOf(track.id) === -1) {
newTracks.push(track);
trackIds.push(track.id);
}
});
playlist.tracks = newTracks;
localStorage.setObject(playlist_id, playlist);
}

View File

@ -4786,8 +4786,8 @@ ngSoundManager.factory('angularPlayer', ['$rootScope', '$log',
// choose one song from [shuffleCount, shufflelist.length-1]
if (shuffleCount == shufflelist.length) {
$log.debug("Shuffle list played finish, no next");
return;
shuffleCount = 0;
shuffleIndex = -1;
}
var index = shuffleCount + Math.floor(Math.random() * (shufflelist.length-shuffleCount));

View File

@ -97,10 +97,10 @@
<label >封面图片url</label>
<input type="text" class="form-control" placeholder="输入歌单名称" ng-model="dialog_cover_img_url"/>
</div>
<button class="btn btn-primary confirm-button" ng-click="editMyPlaylist(list_id)">修改歌单</button>
<button class="btn btn-default" ng-click="closeDialog()">取消</button>
<div class='dialog-footer'>
<div class='dialog-footer'>
<button class="btn btn-danger remove-button" ng-click="removeMyPlaylist(list_id)">删除歌单</button>
</div>
</div>
@ -124,7 +124,7 @@
<button class="btn btn-primary confirm-button" ng-click="openUrl(dialog_url);closeDialog();">打开歌单</button>
<button class="btn btn-default" ng-click="closeDialog()">取消</button>
</div>
<ul ng-show="dialog_type==6" class="dialog-merge-playlist">
<li ng-repeat="playlist in myplaylist track by $index" ng-class-odd="'odd'" ng-class-even="'even'" ng-click="mergePlaylist(playlist.info.id)">
<img ng-src="{{ playlist.info.cover_img_url }}" />
@ -265,10 +265,10 @@
<ul class="nav nav-tabs">
<ul class="nav nav-tabs">
<li ng-class="{'active':isActiveTab(0)}" ng-click="changeTab(0)"><a>网易</a></li>
<li ng-class="{'active':isActiveTab(1)}" ng-click="changeTab(1)"><a href="#">虾米</a></li>
<li ng-class="{'active':isActiveTab(2)}" ng-click="changeTab(2)"><a href="#">QQ音乐</a></li>
<li ng-class="{'active':isActiveTab(2)}" ng-click="changeTab(2)"><a href="#">QQ音乐</a></li>
<li ng-class="{'active':isActiveTab(3)}" ng-click="changeTab(3)" ng-show="isDoubanLogin"><a href="#">豆瓣</a></li>
<img class="searchspinner" id="spinner" src="images/loading.gif" ng-show="loading">
</ul>
@ -280,7 +280,7 @@
</div>
<div class="col1 detail-artist"><a ng-click="showPlaylist(song.artist_id)">{{ song.artist |limitTo:20}}</a></div>
<div class="col2"><a ng-click="showPlaylist(song.album_id)">{{ song.album |limitTo:30}}</a></div>
<div class="detail-tools">
<a title="添加到当前播放" class="detail-add-button" add-without-play="song" ng-show="options"></a>
<a title="添加到歌单" class="detail-fav-button" ng-show="options" ng-click="showDialog(0, song)"></a>
@ -428,7 +428,7 @@
<a class="" ng-click="showPlaylist(currentPlaying.artist_id)">{{ currentPlaying.artist }}</a>
</span>
</span>
<a open-url="currentPlaying.source_url" class="src" title="原始链接"></a>
<a open-url="currentPlaying.source_url" class="src" title="原始链接"></a>
</div>
<div class="m-pbar play" >
@ -466,7 +466,8 @@
<div class="menu" ng-hide="menuHidden">
<div class="menu-header">
<span>播放列表</span>
<a clear-playlist class="remove-all"><small>(移除所有)</small></a>
<a clear-playlist class="remove-all"><small>(移除所有</small></a>
<a class="add-all" ng-click="showDialog(0, playlist)"><small>添加所有到歌单)</small></a>
<a class="close-popup" ng-click="menuHidden=!menuHidden">×</a>
</div>
<ul>