/
PlayListPlayer.cpp
657 lines (566 loc) · 18.3 KB
/
PlayListPlayer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
/*
* Copyright (C) 2005-2008 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "threads/SystemClock.h"
#include "PlayListPlayer.h"
#include "playlists/PlayListFactory.h"
#include "Application.h"
#include "PartyModeManager.h"
#include "settings/AdvancedSettings.h"
#include "GUIUserMessages.h"
#include "guilib/GUIWindowManager.h"
#include "dialogs/GUIDialogOK.h"
#include "playlists/PlayList.h"
#include "utils/log.h"
#include "utils/TimeUtils.h"
#include "music/tags/MusicInfoTag.h"
#include "dialogs/GUIDialogKaiToast.h"
#include "guilib/LocalizeStrings.h"
using namespace PLAYLIST;
CPlayListPlayer::CPlayListPlayer(void)
{
m_PlaylistMusic = new CPlayList;
m_PlaylistVideo = new CPlayList;
m_PlaylistEmpty = new CPlayList;
m_iCurrentSong = -1;
m_bPlayedFirstFile = false;
m_bPlaybackStarted = false;
m_iCurrentPlayList = PLAYLIST_NONE;
for (int i = 0; i < 2; i++)
m_repeatState[i] = REPEAT_NONE;
m_iFailedSongs = 0;
m_failedSongsStart = 0;
}
CPlayListPlayer::~CPlayListPlayer(void)
{
Clear();
delete m_PlaylistMusic;
delete m_PlaylistVideo;
delete m_PlaylistEmpty;
}
bool CPlayListPlayer::OnMessage(CGUIMessage &message)
{
switch (message.GetMessage())
{
case GUI_MSG_NOTIFY_ALL:
if (message.GetParam1() == GUI_MSG_UPDATE_ITEM && message.GetItem())
{
// update our item if necessary
CPlayList &playlist = GetPlaylist(m_iCurrentPlayList);
CFileItemPtr item = boost::static_pointer_cast<CFileItem>(message.GetItem());
playlist.UpdateItem(item.get());
}
break;
case GUI_MSG_PLAYBACK_STOPPED:
{
if (m_iCurrentPlayList != PLAYLIST_NONE && m_bPlaybackStarted)
{
CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_STOPPED, 0, 0, m_iCurrentPlayList, m_iCurrentSong);
g_windowManager.SendThreadMessage(msg);
Reset();
m_iCurrentPlayList = PLAYLIST_NONE;
return true;
}
}
break;
}
return false;
}
int CPlayListPlayer::GetNextSong(int offset) const
{
if (m_iCurrentPlayList == PLAYLIST_NONE)
return -1;
const CPlayList& playlist = GetPlaylist(m_iCurrentPlayList);
if (playlist.size() <= 0)
return -1;
int song = m_iCurrentSong;
// party mode
if (g_partyModeManager.IsEnabled() && GetCurrentPlaylist() == PLAYLIST_MUSIC)
return song + offset;
// wrap around in the case of repeating
if (RepeatedOne(m_iCurrentPlayList))
return song;
song += offset;
if (song >= playlist.size() && Repeated(m_iCurrentPlayList))
song %= playlist.size();
return song;
}
int CPlayListPlayer::GetNextSong()
{
if (m_iCurrentPlayList == PLAYLIST_NONE)
return -1;
CPlayList& playlist = GetPlaylist(m_iCurrentPlayList);
if (playlist.size() <= 0)
return -1;
int iSong = m_iCurrentSong;
// party mode
if (g_partyModeManager.IsEnabled() && GetCurrentPlaylist() == PLAYLIST_MUSIC)
return iSong + 1;
// if repeat one, keep playing the current song if its valid
if (RepeatedOne(m_iCurrentPlayList))
{
// otherwise immediately abort playback
if (m_iCurrentSong >= 0 && m_iCurrentSong < playlist.size() && playlist[m_iCurrentSong]->GetProperty("unplayable").asBoolean())
{
CLog::Log(LOGERROR,"Playlist Player: RepeatOne stuck on unplayable item: %i, path [%s]", m_iCurrentSong, playlist[m_iCurrentSong]->GetPath().c_str());
CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_STOPPED, 0, 0, m_iCurrentPlayList, m_iCurrentSong);
g_windowManager.SendThreadMessage(msg);
Reset();
m_iCurrentPlayList = PLAYLIST_NONE;
return -1;
}
return iSong;
}
// if we've gone beyond the playlist and repeat all is enabled,
// then we clear played status and wrap around
iSong++;
if (iSong >= playlist.size() && Repeated(m_iCurrentPlayList))
iSong = 0;
return iSong;
}
bool CPlayListPlayer::PlayNext(int offset, bool bAutoPlay)
{
int iSong = GetNextSong(offset);
CPlayList& playlist = GetPlaylist(m_iCurrentPlayList);
if ((iSong < 0) || (iSong >= playlist.size()) || (playlist.GetPlayable() <= 0))
{
if(!bAutoPlay)
CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(559), g_localizeStrings.Get(34201));
CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_STOPPED, 0, 0, m_iCurrentPlayList, m_iCurrentSong);
g_windowManager.SendThreadMessage(msg);
Reset();
m_iCurrentPlayList = PLAYLIST_NONE;
return false;
}
return Play(iSong, false);
}
bool CPlayListPlayer::PlayPrevious()
{
if (m_iCurrentPlayList == PLAYLIST_NONE)
return false;
CPlayList& playlist = GetPlaylist(m_iCurrentPlayList);
int iSong = m_iCurrentSong;
if (!RepeatedOne(m_iCurrentPlayList))
iSong--;
if (iSong < 0 && Repeated(m_iCurrentPlayList))
iSong = playlist.size() - 1;
if (iSong < 0 || playlist.size() <= 0)
{
CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(559), g_localizeStrings.Get(34202));
return false;
}
return Play(iSong, false, true);
}
bool CPlayListPlayer::Play()
{
if (m_iCurrentPlayList == PLAYLIST_NONE)
return false;
CPlayList& playlist = GetPlaylist(m_iCurrentPlayList);
if (playlist.size() <= 0)
return false;
return Play(0);
}
bool CPlayListPlayer::PlaySongId(int songId)
{
if (m_iCurrentPlayList == PLAYLIST_NONE)
return false;
CPlayList& playlist = GetPlaylist(m_iCurrentPlayList);
if (playlist.size() <= 0)
return Play();
for (int i = 0; i < playlist.size(); i++)
{
if (playlist[i]->HasMusicInfoTag() && playlist[i]->GetMusicInfoTag()->GetDatabaseId() == songId)
return Play(i);
}
return Play();
}
bool CPlayListPlayer::Play(int iSong, bool bAutoPlay /* = false */, bool bPlayPrevious /* = false */)
{
if (m_iCurrentPlayList == PLAYLIST_NONE)
return false;
CPlayList& playlist = GetPlaylist(m_iCurrentPlayList);
if (playlist.size() <= 0)
return false;
if (iSong < 0)
iSong = 0;
if (iSong >= playlist.size())
iSong = playlist.size() - 1;
// check if the item itself is a playlist, and can be expanded
// only allow a few levels, this could end up in a loop
// if they refer to each other in a loop
for(int i=0;i<5;i++)
{
if(!playlist.Expand(iSong))
break;
}
m_iCurrentSong = iSong;
CFileItemPtr item = playlist[m_iCurrentSong];
playlist.SetPlayed(true);
m_bPlaybackStarted = false;
unsigned int playAttempt = XbmcThreads::SystemClockMillis();
if (!g_application.PlayFile(*item, bAutoPlay))
{
CLog::Log(LOGERROR,"Playlist Player: skipping unplayable item: %i, path [%s]", m_iCurrentSong, item->GetPath().c_str());
playlist.SetUnPlayable(m_iCurrentSong);
// abort on 100 failed CONSECTUTIVE songs
if (!m_iFailedSongs)
m_failedSongsStart = playAttempt;
m_iFailedSongs++;
if ((m_iFailedSongs >= g_advancedSettings.m_playlistRetries && g_advancedSettings.m_playlistRetries >= 0)
|| ((XbmcThreads::SystemClockMillis() - m_failedSongsStart >= (unsigned int)g_advancedSettings.m_playlistTimeout * 1000) && g_advancedSettings.m_playlistTimeout))
{
CLog::Log(LOGDEBUG,"Playlist Player: one or more items failed to play... aborting playback");
// open error dialog
CGUIDialogOK::ShowAndGetInput(16026, 16027, 16029, 0);
CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_STOPPED, 0, 0, m_iCurrentPlayList, m_iCurrentSong);
g_windowManager.SendThreadMessage(msg);
Reset();
GetPlaylist(m_iCurrentPlayList).Clear();
m_iCurrentPlayList = PLAYLIST_NONE;
m_iFailedSongs = 0;
m_failedSongsStart = 0;
return false;
}
// how many playable items are in the playlist?
if (playlist.GetPlayable() > 0)
{
return bPlayPrevious ? PlayPrevious() : PlayNext();
}
// none? then abort playback
else
{
CLog::Log(LOGDEBUG,"Playlist Player: no more playable items... aborting playback");
CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_STOPPED, 0, 0, m_iCurrentPlayList, m_iCurrentSong);
g_windowManager.SendThreadMessage(msg);
Reset();
m_iCurrentPlayList = PLAYLIST_NONE;
return false;
}
}
// TODO - move the above failure logic and the below success logic
// to callbacks instead so we don't rely on the return value
// of PlayFile()
// consecutive error counter so reset if the current item is playing
m_iFailedSongs = 0;
m_failedSongsStart = 0;
m_bPlaybackStarted = true;
m_bPlayedFirstFile = true;
return true;
}
void CPlayListPlayer::SetCurrentSong(int iSong)
{
if (iSong >= -1 && iSong < GetPlaylist(m_iCurrentPlayList).size())
m_iCurrentSong = iSong;
}
int CPlayListPlayer::GetCurrentSong() const
{
return m_iCurrentSong;
}
int CPlayListPlayer::GetCurrentPlaylist() const
{
return m_iCurrentPlayList;
}
void CPlayListPlayer::SetCurrentPlaylist(int iPlaylist)
{
if (iPlaylist == m_iCurrentPlayList)
return;
// changing the current playlist while party mode is on
// disables party mode
if (g_partyModeManager.IsEnabled())
g_partyModeManager.Disable();
m_iCurrentPlayList = iPlaylist;
m_bPlayedFirstFile = false;
}
void CPlayListPlayer::ClearPlaylist(int iPlaylist)
{
// clear our applications playlist file
g_application.m_strPlayListFile.Empty();
CPlayList& playlist = GetPlaylist(iPlaylist);
playlist.Clear();
// its likely that the playlist changed
CGUIMessage msg(GUI_MSG_PLAYLIST_CHANGED, 0, 0);
g_windowManager.SendMessage(msg);
}
CPlayList& CPlayListPlayer::GetPlaylist(int iPlaylist)
{
switch ( iPlaylist )
{
case PLAYLIST_MUSIC:
return *m_PlaylistMusic;
break;
case PLAYLIST_VIDEO:
return *m_PlaylistVideo;
break;
default:
m_PlaylistEmpty->Clear();
return *m_PlaylistEmpty;
break;
}
}
const CPlayList& CPlayListPlayer::GetPlaylist(int iPlaylist) const
{
switch ( iPlaylist )
{
case PLAYLIST_MUSIC:
return *m_PlaylistMusic;
break;
case PLAYLIST_VIDEO:
return *m_PlaylistVideo;
break;
default:
// NOTE: This playlist may not be empty if the caller of the non-const version alters it!
return *m_PlaylistEmpty;
break;
}
}
int CPlayListPlayer::RemoveDVDItems()
{
int nRemovedM = m_PlaylistMusic->RemoveDVDItems();
int nRemovedV = m_PlaylistVideo->RemoveDVDItems();
return nRemovedM + nRemovedV;
}
void CPlayListPlayer::Reset()
{
m_iCurrentSong = -1;
m_bPlayedFirstFile = false;
m_bPlaybackStarted = false;
// its likely that the playlist changed
CGUIMessage msg(GUI_MSG_PLAYLIST_CHANGED, 0, 0);
g_windowManager.SendMessage(msg);
}
bool CPlayListPlayer::HasPlayedFirstFile() const
{
return m_bPlayedFirstFile;
}
bool CPlayListPlayer::Repeated(int iPlaylist) const
{
if (iPlaylist >= PLAYLIST_MUSIC && iPlaylist <= PLAYLIST_VIDEO)
return (m_repeatState[iPlaylist] == REPEAT_ALL);
return false;
}
bool CPlayListPlayer::RepeatedOne(int iPlaylist) const
{
if (iPlaylist == PLAYLIST_MUSIC || iPlaylist == PLAYLIST_VIDEO)
return (m_repeatState[iPlaylist] == REPEAT_ONE);
return false;
}
void CPlayListPlayer::SetShuffle(int iPlaylist, bool bYesNo, bool bNotify /* = false */)
{
if (iPlaylist != PLAYLIST_MUSIC && iPlaylist != PLAYLIST_VIDEO)
return;
// disable shuffle in party mode
if (g_partyModeManager.IsEnabled() && iPlaylist == PLAYLIST_MUSIC)
return;
// do we even need to do anything?
if (bYesNo != IsShuffled(iPlaylist))
{
// save the order value of the current song so we can use it find its new location later
int iOrder = -1;
CPlayList &playlist = GetPlaylist(iPlaylist);
if (m_iCurrentSong >= 0 && m_iCurrentSong < playlist.size())
iOrder = playlist[m_iCurrentSong]->m_iprogramCount;
// shuffle or unshuffle as necessary
if (bYesNo)
playlist.Shuffle();
else
playlist.UnShuffle();
if (bNotify)
{
CStdString shuffleStr;
shuffleStr.Format("%s: %s", g_localizeStrings.Get(191), g_localizeStrings.Get(bYesNo ? 593 : 591)); // Shuffle: All/Off
CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(559), shuffleStr);
}
// find the previous order value and fix the current song marker
if (iOrder >= 0)
{
int iIndex = playlist.FindOrder(iOrder);
if (iIndex >= 0)
m_iCurrentSong = iIndex;
// if iIndex < 0, something unexpected happened
// so dont do anything
}
}
}
bool CPlayListPlayer::IsShuffled(int iPlaylist) const
{
// even if shuffled, party mode says its not
if (g_partyModeManager.IsEnabled() && iPlaylist == PLAYLIST_MUSIC)
return false;
if (iPlaylist == PLAYLIST_MUSIC || iPlaylist == PLAYLIST_VIDEO)
return GetPlaylist(iPlaylist).IsShuffled();
return false;
}
void CPlayListPlayer::SetRepeat(int iPlaylist, REPEAT_STATE state, bool bNotify /* = false */)
{
if (iPlaylist != PLAYLIST_MUSIC && iPlaylist != PLAYLIST_VIDEO)
return;
// disable repeat in party mode
if (g_partyModeManager.IsEnabled() && iPlaylist == PLAYLIST_MUSIC)
state = REPEAT_NONE;
// notify the user if there was a change in the repeat state
if (m_repeatState[iPlaylist] != state && bNotify)
{
int iLocalizedString;
if (state == REPEAT_NONE)
iLocalizedString = 595; // Repeat: Off
else if (state == REPEAT_ONE)
iLocalizedString = 596; // Repeat: One
else
iLocalizedString = 597; // Repeat: All
CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(559), g_localizeStrings.Get(iLocalizedString));
}
m_repeatState[iPlaylist] = state;
}
REPEAT_STATE CPlayListPlayer::GetRepeat(int iPlaylist) const
{
if (iPlaylist == PLAYLIST_MUSIC || iPlaylist == PLAYLIST_VIDEO)
return m_repeatState[iPlaylist];
return REPEAT_NONE;
}
void CPlayListPlayer::ReShuffle(int iPlaylist, int iPosition)
{
// playlist has not played yet so shuffle the entire list
// (this only really works for new video playlists)
if (!GetPlaylist(iPlaylist).WasPlayed())
{
GetPlaylist(iPlaylist).Shuffle();
}
// we're trying to shuffle new items into the curently playing playlist
// so we shuffle starting at two positions below the current item
else if (iPlaylist == m_iCurrentPlayList)
{
if (
(g_application.IsPlayingAudio() && iPlaylist == PLAYLIST_MUSIC) ||
(g_application.IsPlayingVideo() && iPlaylist == PLAYLIST_VIDEO)
)
{
g_playlistPlayer.GetPlaylist(iPlaylist).Shuffle(m_iCurrentSong + 2);
}
}
// otherwise, shuffle from the passed position
// which is the position of the first new item added
else
{
g_playlistPlayer.GetPlaylist(iPlaylist).Shuffle(iPosition);
}
}
void CPlayListPlayer::Add(int iPlaylist, CPlayList& playlist)
{
if (iPlaylist != PLAYLIST_MUSIC && iPlaylist != PLAYLIST_VIDEO)
return;
CPlayList& list = GetPlaylist(iPlaylist);
int iSize = list.size();
list.Add(playlist);
if (list.IsShuffled())
ReShuffle(iPlaylist, iSize);
}
void CPlayListPlayer::Add(int iPlaylist, const CFileItemPtr &pItem)
{
if (iPlaylist != PLAYLIST_MUSIC && iPlaylist != PLAYLIST_VIDEO)
return;
CPlayList& list = GetPlaylist(iPlaylist);
int iSize = list.size();
list.Add(pItem);
if (list.IsShuffled())
ReShuffle(iPlaylist, iSize);
}
void CPlayListPlayer::Add(int iPlaylist, CFileItemList& items)
{
if (iPlaylist != PLAYLIST_MUSIC && iPlaylist != PLAYLIST_VIDEO)
return;
CPlayList& list = GetPlaylist(iPlaylist);
int iSize = list.size();
list.Add(items);
if (list.IsShuffled())
ReShuffle(iPlaylist, iSize);
}
void CPlayListPlayer::Insert(int iPlaylist, CPlayList& playlist, int iIndex)
{
if (iPlaylist != PLAYLIST_MUSIC && iPlaylist != PLAYLIST_VIDEO)
return;
CPlayList& list = GetPlaylist(iPlaylist);
int iSize = list.size();
list.Insert(playlist, iIndex);
if (list.IsShuffled())
ReShuffle(iPlaylist, iSize);
else if (m_iCurrentPlayList == iPlaylist && m_iCurrentSong >= iIndex)
m_iCurrentSong++;
}
void CPlayListPlayer::Insert(int iPlaylist, const CFileItemPtr &pItem, int iIndex)
{
if (iPlaylist != PLAYLIST_MUSIC && iPlaylist != PLAYLIST_VIDEO)
return;
CPlayList& list = GetPlaylist(iPlaylist);
int iSize = list.size();
list.Insert(pItem, iIndex);
if (list.IsShuffled())
ReShuffle(iPlaylist, iSize);
else if (m_iCurrentPlayList == iPlaylist && m_iCurrentSong >= iIndex)
m_iCurrentSong++;
}
void CPlayListPlayer::Insert(int iPlaylist, CFileItemList& items, int iIndex)
{
if (iPlaylist != PLAYLIST_MUSIC && iPlaylist != PLAYLIST_VIDEO)
return;
CPlayList& list = GetPlaylist(iPlaylist);
int iSize = list.size();
list.Insert(items, iIndex);
if (list.IsShuffled())
ReShuffle(iPlaylist, iSize);
else if (m_iCurrentPlayList == iPlaylist && m_iCurrentSong >= iIndex)
m_iCurrentSong++;
}
void CPlayListPlayer::Remove(int iPlaylist, int iPosition)
{
if (iPlaylist != PLAYLIST_MUSIC && iPlaylist != PLAYLIST_VIDEO)
return;
CPlayList& list = GetPlaylist(iPlaylist);
list.Remove(iPosition);
if (m_iCurrentPlayList == iPlaylist && m_iCurrentSong >= iPosition)
m_iCurrentSong--;
// its likely that the playlist changed
CGUIMessage msg(GUI_MSG_PLAYLIST_CHANGED, 0, 0);
g_windowManager.SendMessage(msg);
}
void CPlayListPlayer::Clear()
{
if (m_PlaylistMusic)
m_PlaylistMusic->Clear();
if (m_PlaylistVideo)
m_PlaylistVideo->Clear();
if (m_PlaylistEmpty)
m_PlaylistEmpty->Clear();
}
void CPlayListPlayer::Swap(int iPlaylist, int indexItem1, int indexItem2)
{
if (iPlaylist != PLAYLIST_MUSIC && iPlaylist != PLAYLIST_VIDEO)
return;
CPlayList& list = GetPlaylist(iPlaylist);
if (list.Swap(indexItem1, indexItem2) && iPlaylist == m_iCurrentPlayList)
{
if (m_iCurrentSong == indexItem1)
m_iCurrentSong = indexItem2;
else if (m_iCurrentSong == indexItem2)
m_iCurrentSong = indexItem1;
}
// its likely that the playlist changed
CGUIMessage msg(GUI_MSG_PLAYLIST_CHANGED, 0, 0);
g_windowManager.SendMessage(msg);
}