[gnome-music/wip/jfelder/mpris-limit-songs: 4/6] player: Simplify get_songs method
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/mpris-limit-songs: 4/6] player: Simplify get_songs method
- Date: Tue, 18 Sep 2018 16:30:49 +0000 (UTC)
commit ed08ec3c84e792f9922f3d3345a74c5aa8481aa9
Author: Jean Felder <jfelder src gnome org>
Date: Thu Sep 13 22:44:01 2018 +0200
player: Simplify get_songs method
Remove the validation field from the returned list. This method is
only used by mpris which does not need it.
gnomemusic/mpris.py | 9 ++++-----
gnomemusic/player.py | 13 ++++++++-----
2 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index b103c50c..5a33d846 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -26,7 +26,7 @@
import codecs
from gnomemusic.gstplayer import Playback
-from gnomemusic.player import PlayerField, PlayerPlaylist, RepeatMode
+from gnomemusic.player import PlayerPlaylist, RepeatMode
from gnomemusic.grilo import grilo
from gnomemusic.playlists import Playlists
from gnomemusic.utils import View
@@ -350,8 +350,7 @@ class MediaPlayer2Service(Server):
@log
def _get_media_from_id(self, track_id):
- for track in self.player.get_songs():
- media = track[PlayerField.SONG]
+ for media in self.player.get_songs():
if track_id == self._get_media_id(media):
return media
return None
@@ -359,7 +358,7 @@ class MediaPlayer2Service(Server):
@log
def _get_track_list(self):
if self.player.props.playing:
- return [self._get_media_id(song[PlayerField.SONG])
+ return [self._get_media_id(song)
for song in self.player.get_songs()]
else:
return []
@@ -582,7 +581,7 @@ class MediaPlayer2Service(Server):
def GoTo(self, track_id):
for index, song in enumerate(self.player.get_songs()):
- if track_id == self._get_media_id(song[PlayerField.SONG]):
+ if track_id == self._get_media_id(song):
self.player_play(index)
return
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 644a6ee2..a4903458 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -476,13 +476,11 @@ class PlayerPlaylist(GObject.GObject):
def get_songs(self):
"""Get the current playlist.
- Each member of the list has two elements: the song, and the validation
- status.
-
:returns: current playlist
- :rtype: list
+ :rtype: list of Grl.Media
"""
- return self._songs
+ songs = [elt[PlayerField.SONG] for elt in self._songs]
+ return songs
class Player(GObject.GObject):
@@ -860,4 +858,9 @@ class Player(GObject.GObject):
@log
def get_songs(self):
+ """Get the current playlist.
+
+ :returns: current playlist
+ :rtype: list of Grl.Media
+ """
return self._playlist.get_songs()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]