Bug 1284387 - Remove audio control notification after playing tab has been closed. r=ahunt

MozReview-Commit-ID: 9nrlKpcedzQ

--HG--
extra : rebase_source : 06b3e7b26ca4e5007150780446346eedc9a63653
This commit is contained in:
Sebastian Kaspari 2016-07-21 15:33:48 +02:00
Родитель d29928ce19
Коммит d3f6c0eed6
1 изменённых файлов: 16 добавлений и 6 удалений

Просмотреть файл

@ -102,13 +102,23 @@ public class MediaControlService extends Service implements Tabs.OnTabsChangedLi
return;
}
if (tab == mTabReference.get()) {
return;
}
switch (msg) {
case AUDIO_PLAYING_CHANGE:
if (tab == mTabReference.get()) {
return;
}
if (msg == Tabs.TabEvents.AUDIO_PLAYING_CHANGE && tab.isAudioPlaying()) {
mTabReference = new WeakReference<Tab>(tab);
notifyControlInterfaceChanged(ACTION_PAUSE);
mTabReference = new WeakReference<>(tab);
notifyControlInterfaceChanged(ACTION_PAUSE);
break;
case CLOSED:
final Tab playingTab = mTabReference.get();
if (playingTab == null || playingTab == tab) {
// The playing tab disappeared or was closed. Remove the controls and stop the service.
notifyControlInterfaceChanged(ACTION_REMOVE_CONTROL);
}
break;
}
}