Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximper-shell-notification-center
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
ximper-shell-notification-center
Commits
c05acfa8
Unverified
Commit
c05acfa8
authored
May 11, 2023
by
Erik Reider
Committed by
GitHub
May 11, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed mpDris2 mpris issues (#253)
parent
31002496
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
29 deletions
+32
-29
interfaces.vala
src/controlCenter/widgets/mpris/interfaces.vala
+6
-6
mpris_player.vala
src/controlCenter/widgets/mpris/mpris_player.vala
+26
-23
No files found.
src/controlCenter/widgets/mpris/interfaces.vala
View file @
c05acfa8
...
...
@@ -68,12 +68,12 @@ namespace SwayNotificationCenter.Widgets.Mpris {
[
DBus
(
name
=
"org.mpris.MediaPlayer2.Player"
)]
public
interface
MprisMediaPlayer
:
MprisProps
{
public
abstract
void
next
()
throws
Error
;
public
abstract
void
previous
()
throws
Error
;
public
abstract
void
pause
()
throws
Error
;
public
abstract
void
play_pause
()
throws
Error
;
public
abstract
void
stop
()
throws
Error
;
public
abstract
void
play
()
throws
Error
;
public
abstract
async
void
next
()
throws
Error
;
public
abstract
async
void
previous
()
throws
Error
;
public
abstract
async
void
pause
()
throws
Error
;
public
abstract
async
void
play_pause
()
throws
Error
;
public
abstract
async
void
stop
()
throws
Error
;
public
abstract
async
void
play
()
throws
Error
;
public
abstract
string
playback_status
{
owned
get
;
}
public
abstract
HashTable
<
string
,
Variant
>
metadata
{
owned
get
;
}
...
...
src/controlCenter/widgets/mpris/mpris_player.vala
View file @
c05acfa8
...
...
@@ -77,29 +77,21 @@ namespace SwayNotificationCenter.Widgets.Mpris {
});
// Prev
button_prev
.
clicked
.
connect
(()
=>
{
try
{
source
.
media_player
.
previous
();
}
catch
(
Error
e
)
{
error
(
"Previous Error: %s"
,
e
.
message
);
}
source
.
media_player
.
previous
.
begin
(()
=>
{
update_buttons
(
source
.
media_player
.
metadata
);
});
});
// Next
button_next
.
clicked
.
connect
(()
=>
{
try
{
source
.
media_player
.
next
();
}
catch
(
Error
e
)
{
error
(
"Next Error: %s"
,
e
.
message
);
}
source
.
media_player
.
next
.
begin
(()
=>
{
update_buttons
(
source
.
media_player
.
metadata
);
});
});
// Play/Pause
button_play_pause
.
clicked
.
connect
(()
=>
{
try
{
source
.
media_player
.
play_pause
();
// Wait until dbus value has updated
button_play_pause
.
sensitive
=
false
;
}
catch
(
Error
e
)
{
error
(
"PlayPause Error: %s"
,
e
.
message
);
}
source
.
media_player
.
play_pause
.
begin
(()
=>
{
update_buttons
(
source
.
media_player
.
metadata
);
});
});
}
...
...
@@ -137,11 +129,7 @@ namespace SwayNotificationCenter.Widgets.Mpris {
update_button_forward
(
metadata
);
break
;
case
"CanControl"
:
update_button_shuffle
(
metadata
);
update_button_repeat
(
metadata
);
update_button_prev
(
metadata
);
update_button_forward
(
metadata
);
update_button_play_pause
(
metadata
);
update_buttons
(
metadata
);
break
;
}
}
...
...
@@ -163,6 +151,11 @@ namespace SwayNotificationCenter.Widgets.Mpris {
// Subtitle
update_sub_title
(
metadata
);
// Update the buttons
update_buttons
(
metadata
);
}
private
void
update_buttons
(
HashTable
<
string
,
Variant
>
metadata
)
{
// Shuffle check
update_button_shuffle
(
metadata
);
...
...
@@ -294,6 +287,8 @@ namespace SwayNotificationCenter.Widgets.Mpris {
}
private
void
update_button_shuffle
(
HashTable
<
string
,
Variant
>
metadata
)
{
if
(!(
button_shuffle
is
Gtk
.
Widget
))
return
;
if
(
source
.
media_player
.
can_control
)
{
// Shuffle check
Variant
?
shuffle
=
source
.
get_mpris_player_prop
(
"Shuffle"
);
...
...
@@ -312,15 +307,19 @@ namespace SwayNotificationCenter.Widgets.Mpris {
}
private
void
update_button_prev
(
HashTable
<
string
,
Variant
>
metadata
)
{
if
(!(
button_prev
is
Gtk
.
Widget
))
return
;
button_prev
.
set_sensitive
(
source
.
media_player
.
can_go_previous
&&
source
.
media_player
.
can_control
);
}
private
void
update_button_play_pause
(
HashTable
<
string
,
Variant
>
metadata
)
{
if
(!(
button_play_pause
is
Gtk
.
Widget
))
return
;
string
icon_name
;
bool
check
;
switch
(
source
.
media_player
.
playback_status
)
{
case
"Playing"
:
case
"Playing"
:
icon_name
=
ICON_PAUSE
;
check
=
source
.
media_player
.
can_pause
;
break
;
...
...
@@ -336,11 +335,15 @@ namespace SwayNotificationCenter.Widgets.Mpris {
}
private
void
update_button_forward
(
HashTable
<
string
,
Variant
>
metadata
)
{
if
(!(
button_next
is
Gtk
.
Widget
))
return
;
button_next
.
set_sensitive
(
source
.
media_player
.
can_go_next
&&
source
.
media_player
.
can_control
);
}
private
void
update_button_repeat
(
HashTable
<
string
,
Variant
>
metadata
)
{
if
(!(
button_repeat
is
Gtk
.
Widget
))
return
;
if
(
source
.
media_player
.
can_control
)
{
// Repeat check
Variant
?
repeat
=
source
.
get_mpris_player_prop
(
"LoopStatus"
);
...
...
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