277
276
m_currentId = aalMediaPlaylistProvider()->trackOfIndex(m_currentIndex);
279
void AalMediaPlaylistControl::onMediaRemoved(int start, int end)
284
// If the entire playlist is cleared, we need to reset the currentIndex
285
// to just before the beginning of the list, otherwise if the user selects
286
// a random track in the tracklist for a second time, track 0 is always
287
// selected instead of the desired track index
288
if (aalMediaPlaylistProvider()->mediaCount() == 0)
290
qDebug() << "Tracklist was cleared, resetting m_currentIndex to 0";
296
void AalMediaPlaylistControl::onRemoveTracks(int start, int end)
298
// If the current track and everything after has been removed
299
// then we need to set the currentIndex to 0 otherwise it is
300
// left at the position it was before removing
301
if (start <= m_currentIndex
302
and m_currentIndex <= end
303
and (end + 1) == m_playlistProvider->mediaCount()
309
// When repeat is off we have reached the end of playback so stop
310
if (playbackMode() == QMediaPlaylist::Sequential)
312
qDebug() << "Repeat is off, so stopping playback";
313
m_hubPlayerSession->stop();
280
318
void AalMediaPlaylistControl::onCurrentIndexChanged()
282
int index = aalMediaPlaylistProvider()->indexOfTrack(m_currentId);
320
const int index = aalMediaPlaylistProvider()->indexOfTrack(m_currentId);
284
321
if (index != m_currentIndex) {
285
qDebug() << "Index changed to " << index;
322
qDebug() << "Index changed to" << index;
286
323
m_currentIndex = index;
287
324
Q_EMIT currentIndexChanged(m_currentIndex);
344
381
connect(aalMediaPlaylistProvider(), &AalMediaPlaylistProvider::startMoveTrack,
345
382
this, &AalMediaPlaylistControl::onStartMoveTrack);
384
connect(aalMediaPlaylistProvider(), &AalMediaPlaylistProvider::mediaRemoved,
385
this, &AalMediaPlaylistControl::onMediaRemoved);
387
connect(aalMediaPlaylistProvider(), &AalMediaPlaylistProvider::removeTracks,
388
this, &AalMediaPlaylistControl::onRemoveTracks);
348
391
void AalMediaPlaylistControl::disconnect_signals()