Changeset View
Changeset View
Standalone View
Standalone View
src/core/meta/support/MetaUtility.cpp
Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Line(s) | 61 | { | |||
---|---|---|---|---|---|
108 | map.insert( Meta::Field::FIRST_PLAYED, QVariant( statistics->firstPlayed() ) ); | 108 | map.insert( Meta::Field::FIRST_PLAYED, QVariant( statistics->firstPlayed() ) ); | ||
109 | 109 | | |||
110 | return map; | 110 | return map; | ||
111 | } | 111 | } | ||
112 | 112 | | |||
113 | QVariantMap | 113 | QVariantMap | ||
114 | Meta::Field::mprisMapFromTrack( const Meta::TrackPtr track ) | 114 | Meta::Field::mprisMapFromTrack( const Meta::TrackPtr track ) | ||
115 | { | 115 | { | ||
116 | DEBUG_BLOCK | ||||
117 | | ||||
116 | QVariantMap map; | 118 | QVariantMap map; | ||
117 | if( track ) | 119 | if( track ) | ||
118 | { | 120 | { | ||
119 | // MANDATORY: | 121 | // MANDATORY: | ||
120 | map["location"] = track->playableUrl().url(); | 122 | map["location"] = track->playableUrl().url(); | ||
121 | // INFORMATIONAL: | 123 | // INFORMATIONAL: | ||
122 | map["title"] = track->prettyName(); | 124 | map["title"] = track->prettyName(); | ||
123 | 125 | | |||
124 | if( track->artist() ) | 126 | if( track->artist() ) | ||
125 | map["artist"] = track->artist()->name(); | 127 | map["artist"] = track->artist()->name(); | ||
126 | 128 | | |||
127 | if( track->album() ) | 129 | if( track->album() ) | ||
128 | { | 130 | { | ||
129 | map["album"] = track->album()->name(); | 131 | map["album"] = track->album()->name(); | ||
130 | if( track->album()->hasAlbumArtist() && !track->album()->albumArtist()->name().isEmpty() ) | 132 | if( track->album()->hasAlbumArtist() && !track->album()->albumArtist()->name().isEmpty() ) | ||
131 | map[ "albumartist" ] = track->album()->albumArtist()->name(); | 133 | map[ "albumartist" ] = track->album()->albumArtist()->name(); | ||
132 | 134 | | |||
133 | QImage image = track->album()->image(); | | |||
134 | QUrl url = track->album()->imageLocation(); | 135 | QUrl url = track->album()->imageLocation(); | ||
135 | if ( url.isValid() && !url.isLocalFile() ) { | 136 | if ( url.isValid() && !url.isLocalFile() ) | ||
137 | { | ||||
136 | // embedded id? Request a version to be put in the cache | 138 | // embedded id? Request a version to be put in the cache | ||
139 | QImage image = track->album()->image(); | ||||
137 | int width = track->album()->image().width(); | 140 | int width = track->album()->image().width(); | ||
138 | url = track->album()->imageLocation( width ); | 141 | url = track->album()->imageLocation( width ); | ||
139 | debug() << "MPRIS: New location for width" << width << "is" << url; | 142 | debug() << "MPRIS: New location for width" << width << "is" << url; | ||
140 | } | 143 | } | ||
141 | if ( url.isValid() && url.isLocalFile() ) | 144 | if ( url.isValid() && url.isLocalFile() ) | ||
142 | map["arturl"] = QString::fromLatin1( url.toEncoded() ); | 145 | map["arturl"] = QString::fromLatin1( url.toEncoded() ); | ||
143 | } | 146 | } | ||
144 | 147 | | |||
Show All 23 Lines | 170 | if( !lyrics.isEmpty() ) | |||
168 | map["lyrics"] = lyrics; | 171 | map["lyrics"] = lyrics; | ||
169 | } | 172 | } | ||
170 | return map; | 173 | return map; | ||
171 | } | 174 | } | ||
172 | 175 | | |||
173 | QVariantMap | 176 | QVariantMap | ||
174 | Meta::Field::mpris20MapFromTrack( const Meta::TrackPtr track ) | 177 | Meta::Field::mpris20MapFromTrack( const Meta::TrackPtr track ) | ||
175 | { | 178 | { | ||
179 | DEBUG_BLOCK | ||||
180 | | ||||
176 | QVariantMap map; | 181 | QVariantMap map; | ||
177 | if( track ) | 182 | if( track ) | ||
178 | { | 183 | { | ||
179 | // We do not set mpris::trackid here because it depends on the position | 184 | // We do not set mpris::trackid here because it depends on the position | ||
180 | // of the track in the playlist | 185 | // of the track in the playlist | ||
181 | map["mpris:length"] = track->length() * 1000; // microseconds | 186 | map["mpris:length"] = track->length() * 1000; // microseconds | ||
182 | 187 | | |||
183 | // get strong pointers (BR 317980) | 188 | // get strong pointers (BR 317980) | ||
184 | Meta::AlbumPtr album = track->album(); | 189 | Meta::AlbumPtr album = track->album(); | ||
185 | Meta::ArtistPtr artist = track->artist(); | 190 | Meta::ArtistPtr artist = track->artist(); | ||
186 | Meta::ComposerPtr composer = track->composer(); | 191 | Meta::ComposerPtr composer = track->composer(); | ||
187 | Meta::YearPtr year = track->year(); | 192 | Meta::YearPtr year = track->year(); | ||
188 | Meta::GenrePtr genre = track->genre(); | 193 | Meta::GenrePtr genre = track->genre(); | ||
189 | Meta::ConstStatisticsPtr statistics = track->statistics(); | 194 | Meta::ConstStatisticsPtr statistics = track->statistics(); | ||
190 | 195 | | |||
191 | if( album ) { | 196 | if( album ) { | ||
192 | QImage image = album->image(); | | |||
193 | QUrl url = album->imageLocation(); | 197 | QUrl url = album->imageLocation(); | ||
194 | debug() << "MPRIS2: Album image location is" << url; | 198 | debug() << "MPRIS2: Album image location is" << url; | ||
195 | if ( url.isValid() && !url.isLocalFile() ) | 199 | if ( url.isValid() && !url.isLocalFile() ) | ||
196 | { | 200 | { | ||
197 | // embedded id? Request a version to be put in the cache | 201 | // embedded id? Request a version to be put in the cache | ||
202 | QImage image = album->image(); | ||||
198 | int width = album->image().width(); | 203 | int width = album->image().width(); | ||
199 | url = album->imageLocation( width ); | 204 | url = album->imageLocation( width ); | ||
200 | debug() << "MPRIS2: New location for width" << width << "is" << url; | 205 | debug() << "MPRIS2: New location for width" << width << "is" << url; | ||
201 | } | 206 | } | ||
202 | if ( url.isValid() && url.isLocalFile() ) | 207 | if ( url.isValid() && url.isLocalFile() ) | ||
203 | map["mpris:artUrl"] = QString::fromLatin1( url.toEncoded() ); | 208 | map["mpris:artUrl"] = QString::fromLatin1( url.toEncoded() ); | ||
204 | 209 | | |||
205 | map["xesam:album"] = album->name(); | 210 | map["xesam:album"] = album->name(); | ||
▲ Show 20 Lines • Show All 261 Lines • Show Last 20 Lines |