Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
KDE Connect Android
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
25
Merge Requests
25
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Network
KDE Connect Android
Commits
f688aad3
Commit
f688aad3
authored
Jun 14, 2019
by
Matthijs Tijink
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Close the MPRIS media notification when the player disappears
The code now checks if the player still exists.
parent
906c04ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
18 deletions
+26
-18
src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java
...kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java
+22
-18
src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java
src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java
+4
-0
No files found.
src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java
View file @
f688aad3
...
...
@@ -191,46 +191,44 @@ public class MprisMediaSession implements SharedPreferences.OnSharedPreferenceCh
}
private
Pair
<
Device
,
MprisPlugin
.
MprisPlayer
>
findPlayer
(
BackgroundService
service
)
{
//First try the previously displayed player (if still playing)
//First try the previously displayed player (if still playing)
or the previous displayed device (otherwise)
if
(
notificationDevice
!=
null
&&
mprisDevices
.
contains
(
notificationDevice
))
{
Device
device
=
service
.
getDevice
(
notificationDevice
);
if
(
device
!=
null
&&
device
.
isPluginEnabled
(
"MprisPlugin"
))
{
if
(
shouldShowPlayer
(
notificationPlayer
)
&&
notificationPlayer
.
isPlaying
())
{
return
new
Pair
<>(
device
,
notificationPlayer
);
}
// Try a different player for the same device
MprisPlugin
.
MprisPlayer
player
=
getPlayerFromDevice
(
device
);
if
(
player
!=
null
)
{
return
new
Pair
<>(
device
,
player
);
}
MprisPlugin
.
MprisPlayer
player
;
if
(
notificationPlayer
.
isPlaying
())
{
player
=
getPlayerFromDevice
(
device
,
notificationPlayer
);
}
else
{
player
=
getPlayerFromDevice
(
device
,
null
);
}
if
(
player
!=
null
)
{
return
new
Pair
<>(
device
,
player
);
}
}
// Try a different player from another device
for
(
Device
otherDevice
:
service
.
getDevices
().
values
())
{
MprisPlugin
.
MprisPlayer
player
=
getPlayerFromDevice
(
otherDevice
);
MprisPlugin
.
MprisPlayer
player
=
getPlayerFromDevice
(
otherDevice
,
null
);
if
(
player
!=
null
)
{
return
new
Pair
<>(
otherDevice
,
player
);
}
}
//So no player is playing. Try the previously displayed player again
// This will succeed if it's paused:
// that allows pausing and subsequently resuming via the notification
if
(
notificationDevice
!=
null
&&
mprisDevices
.
contains
(
notificationDevice
))
{
Device
device
=
service
.
getDevice
(
notificationDevice
);
if
(
device
!=
null
&&
device
.
isPluginEnabled
(
"MprisPlugin"
))
{
if
(
shouldShowPlayer
(
notificationPlayer
))
{
return
new
Pair
<>(
device
,
notificationPlayer
);
}
MprisPlugin
.
MprisPlayer
player
=
getPlayerFromDevice
(
device
,
notificationPlayer
);
if
(
player
!=
null
)
{
return
new
Pair
<>(
device
,
player
);
}
}
return
new
Pair
<>(
null
,
null
);
}
private
MprisPlugin
.
MprisPlayer
getPlayerFromDevice
(
Device
device
)
{
private
MprisPlugin
.
MprisPlayer
getPlayerFromDevice
(
Device
device
,
MprisPlugin
.
MprisPlayer
preferredPlayer
)
{
if
(!
mprisDevices
.
contains
(
device
.
getDeviceId
()))
return
null
;
...
...
@@ -240,6 +238,12 @@ public class MprisMediaSession implements SharedPreferences.OnSharedPreferenceCh
return
null
;
}
//First try the preferred player, if supplied
if
(
plugin
.
hasPlayer
(
preferredPlayer
)
&&
shouldShowPlayer
(
preferredPlayer
))
{
return
preferredPlayer
;
}
//Otherwise, accept any playing player
MprisPlugin
.
MprisPlayer
player
=
plugin
.
getPlayingPlayer
();
if
(
shouldShowPlayer
(
player
))
{
return
player
;
...
...
src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java
View file @
f688aad3
...
...
@@ -422,6 +422,10 @@ public class MprisPlugin extends Plugin {
return
null
;
}
boolean
hasPlayer
(
MprisPlayer
player
)
{
return
players
.
containsValue
(
player
);
}
private
void
requestPlayerList
()
{
NetworkPacket
np
=
new
NetworkPacket
(
PACKET_TYPE_MPRIS_REQUEST
);
np
.
set
(
"requestPlayerList"
,
true
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment