[rygel/wip/739692: 7/7] server, media-export: Lookup media art for videos
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/739692: 7/7] server, media-export: Lookup media art for videos
- Date: Tue, 11 Nov 2014 21:25:45 +0000 (UTC)
commit 5cb45ee45237ba5993636fc76192584ac51256a6
Author: Jens Georg <mail jensge org>
Date: Tue Nov 11 22:23:29 2014 +0100
server,media-export: Lookup media art for videos
Signed-off-by: Jens Georg <mail jensge org>
src/librygel-server/rygel-media-art-store.vala | 7 +++-
src/librygel-server/rygel-video-item.vala | 27 ++++++++++++++++++++
.../rygel-media-export-media-cache.vala | 5 +++
3 files changed, 37 insertions(+), 2 deletions(-)
---
diff --git a/src/librygel-server/rygel-media-art-store.vala b/src/librygel-server/rygel-media-art-store.vala
index 3f2f35b..338012d 100644
--- a/src/librygel-server/rygel-media-art-store.vala
+++ b/src/librygel-server/rygel-media-art-store.vala
@@ -57,14 +57,17 @@ public class Rygel.MediaArtStore : GLib.Object {
return media_art_store;
}
- public Thumbnail? lookup_media_art (MusicItem item) throws Error {
+ public Thumbnail? lookup_media_art (MediaItem item) throws Error {
File file = null;
foreach (var type in MediaArtStore.types) {
MediaArt.get_file (item.artist,
- type == "album" ? item.album : item.title,
+ (type == "album" && item is MusicItem) ?
+ (item as MusicItem).album : item.title,
type,
out file);
+ message ("Trying to find file for type %s and %s -> %s",
+ item.title, type, file != null ? file.get_uri () : "None");
if (file != null && file.query_exists (null)) {
break;
diff --git a/src/librygel-server/rygel-video-item.vala b/src/librygel-server/rygel-video-item.vala
index 40bb464..52dfbf5 100644
--- a/src/librygel-server/rygel-video-item.vala
+++ b/src/librygel-server/rygel-video-item.vala
@@ -61,6 +61,10 @@ public class Rygel.VideoItem : AudioItem, VisualItem {
*/
public ArrayList<Thumbnail> thumbnails { get; protected set; }
+ /// Media art for the video (poster etc.)
+ public Thumbnail media_art { get; protected set; }
+
+ /// Subtitles associated with this video
public ArrayList<Subtitle> subtitles { get; protected set; }
public VideoItem (string id,
@@ -223,4 +227,27 @@ public class Rygel.VideoItem : AudioItem, VisualItem {
this.add_thumbnail_proxy_resources (server, didl_item);
}
}
+
+ public void lookup_media_art () {
+ if (this.media_art != null) {
+ return;
+ }
+
+ var media_art_store = MediaArtStore.get_default ();
+ if (media_art_store == null) {
+ return;
+ }
+
+ try {
+ this.media_art = media_art_store.lookup_media_art (this);
+
+ // Add media art as first thumbnail until we get albumArt support
+ // for non-music items
+ if (this.media_art != null) {
+ this.thumbnails.insert (0, this.media_art);
+ }
+ } catch (Error error) {
+ debug ("Failed to look up album art: %s", error.message);
+ };
+ }
}
diff --git a/src/plugins/media-export/rygel-media-export-media-cache.vala
b/src/plugins/media-export/rygel-media-export-media-cache.vala
index 3221e61..f37bb7b 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -961,6 +961,11 @@ public class Rygel.MediaExport.MediaCache : Object {
visual_item.height = statement.column_int (DetailColumn.HEIGHT);
visual_item.color_depth = statement.column_int
(DetailColumn.COLOR_DEPTH);
+ if (item is VideoItem) {
+ var video_item = item as VideoItem;
+
+ video_item.lookup_media_art ();
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]