Merge lp:~phablet-team/media-hub/track-length into lp:media-hub

Proposed by Jim Hodapp
Status: Merged
Approved by: Scott Sweeny
Approved revision: 197
Merged at revision: 196
Proposed branch: lp:~phablet-team/media-hub/track-length
Merge into: lp:media-hub
Diff against target: 77 lines (+20/-0)
4 files modified
include/core/media/track.h (+2/-0)
src/core/media/gstreamer/playbin.h (+2/-0)
src/core/media/metadata.cpp (+10/-0)
src/core/media/player_implementation.cpp (+6/-0)
To merge this branch: bzr merge lp:~phablet-team/media-hub/track-length
Reviewer Review Type Date Requested Status
Scott Sweeny (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+298462@code.launchpad.net

Commit message

Export the current track length per the MPRIS spec.

Description of the change

Export the current track length per the MPRIS spec.

To post a comment you must log in.
Revision history for this message
Scott Sweeny (ssweeny) wrote :

LGTM.

review: Approve
198. By Jim Hodapp

Fix the comment typo

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/core/media/track.h'
2--- include/core/media/track.h 2016-06-15 17:49:49 +0000
3+++ include/core/media/track.h 2016-06-27 21:27:20 +0000
4@@ -117,6 +117,7 @@
5 const std::string& artist() const;
6 const std::string& title() const;
7 const std::string& track_id() const;
8+ const std::string& track_length() const;
9 const std::string& art_url() const;
10 const std::string& last_used() const;
11
12@@ -124,6 +125,7 @@
13 void set_artist(const std::string& artist);
14 void set_title(const std::string& title);
15 void set_track_id(const std::string& id);
16+ void set_track_length(const std::string& id);
17 void set_art_url(const std::string& url);
18 void set_last_used(const std::string& datetime);
19
20
21=== modified file 'src/core/media/gstreamer/playbin.h'
22--- src/core/media/gstreamer/playbin.h 2016-02-19 16:14:42 +0000
23+++ src/core/media/gstreamer/playbin.h 2016-06-27 21:27:20 +0000
24@@ -88,7 +88,9 @@
25 /** Sets the new audio stream role on the pulsesink in playbin */
26 void set_audio_stream_role(core::ubuntu::media::Player::AudioStreamRole new_audio_role);
27
28+ /** Returns the current stream position in nanoseconds */
29 uint64_t position() const;
30+ /** Returns the current stream duration in nanoseconds */
31 uint64_t duration() const;
32
33 void set_uri(const std::string& uri, const core::ubuntu::media::Player::HeadersType& headers, bool do_pipeline_reset = true);
34
35=== modified file 'src/core/media/metadata.cpp'
36--- src/core/media/metadata.cpp 2016-06-15 17:49:49 +0000
37+++ src/core/media/metadata.cpp 2016-06-27 21:27:20 +0000
38@@ -54,6 +54,11 @@
39 return map.at(media::Track::MetaData::TrackIdKey);
40 }
41
42+const std::string& media::Track::MetaData::track_length() const
43+{
44+ return map.at(media::Track::MetaData::TrackLengthKey);
45+}
46+
47 const std::string& media::Track::MetaData::art_url() const
48 {
49 return map.at(media::Track::MetaData::TrackArtlUrlKey);
50@@ -84,6 +89,11 @@
51 map[media::Track::MetaData::TrackIdKey] = id;
52 }
53
54+void media::Track::MetaData::set_track_length(const std::string& length)
55+{
56+ map[media::Track::MetaData::TrackLengthKey] = length;
57+}
58+
59 void media::Track::MetaData::set_art_url(const std::string& url)
60 {
61 map[media::Track::MetaData::TrackArtlUrlKey] = url;
62
63=== modified file 'src/core/media/player_implementation.cpp'
64--- src/core/media/player_implementation.cpp 2016-06-23 00:17:16 +0000
65+++ src/core/media/player_implementation.cpp 2016-06-27 21:27:20 +0000
66@@ -408,6 +408,12 @@
67 if (not metadata.is_set(media::Track::MetaData::TrackArtlUrlKey))
68 metadata.set_art_url(get_uri_for_album_artwork(uri, metadata));
69
70+ if (not metadata.is_set(media::Track::MetaData::TrackLengthKey))
71+ {
72+ // Duration is in nanoseconds, MPRIS spec requires microseconds
73+ metadata.set_track_length(std::to_string(engine->duration().get() / 1000));
74+ }
75+
76 parent->meta_data_for_current_track().set(metadata);
77 }
78

Subscribers

People subscribed via source and target branches

to all changes: