diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-01-19 19:45:55 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-01-19 19:45:55 -0800 |
commit | e4bfbeab9bf2c41f957d9152eac6f80e18d0073b (patch) | |
tree | 92bf1189b7a498440fe458bfa032884c7615af0d /src | |
parent | bf43b264b32e33bb5de556da4dff521a1f894472 (diff) | |
download | dsub-e4bfbeab9bf2c41f957d9152eac6f80e18d0073b.tar.gz dsub-e4bfbeab9bf2c41f957d9152eac6f80e18d0073b.tar.bz2 dsub-e4bfbeab9bf2c41f957d9152eac6f80e18d0073b.zip |
Get some basic metadata working
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/service/DLNAController.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/github/daneren2005/dsub/service/DLNAController.java b/src/github/daneren2005/dsub/service/DLNAController.java index 1ad48ef2..fc19b6a1 100644 --- a/src/github/daneren2005/dsub/service/DLNAController.java +++ b/src/github/daneren2005/dsub/service/DLNAController.java @@ -340,7 +340,25 @@ public class DLNAController extends RemoteController { if(song.isVideo()) {
track = new VideoItem(song.getId(), song.getParent(), song.getTitle(), song.getArtist());
} else {
- MusicTrack musicTrack = new MusicTrack(song.getId(), song.getParent(), song.getTitle(), song.getArtist(), song.getAlbum(), song.getArtist());
+ String contentType = song.getTranscodedContentType();
+ MimeType mimeType;
+ // If we can parse the content type, use it instead of hard coding
+ if(contentType.indexOf("/") != -1 && contentType.indexOf("/") != (contentType.length() - 1)) {
+ String[] typeParts = contentType.split("/");
+ mimeType = new MimeType(typeParts[0], typeParts[1]);
+ } else {
+ mimeType = new MimeType("audio", "mpeg");
+ }
+
+ Res res = new Res(mimeType, song.getSize(), url);
+
+ if(song.getDuration() != null) {
+ SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
+ df.setTimeZone(TimeZone.getTimeZone("UTC"));
+ res.setDuration(df.format(new Date(song.getDuration() * 1000)));
+ }
+
+ MusicTrack musicTrack = new MusicTrack(song.getId(), song.getParent(), song.getTitle(), song.getArtist(), song.getAlbum(), song.getArtist(), res);
musicTrack.setOriginalTrackNumber(song.getTrack());
track = musicTrack;
}
@@ -352,7 +370,7 @@ public class DLNAController extends RemoteController { String metadata = "";
try {
// <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><CurrentURI>http://192.168.1.3:57645/external/audio/media/39883.mp3</CurrentURI><CurrentURIMetaData><DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" xmlns:sec="http://www.sec.co.kr/"><item id="/external/audio/albums/484/39883" parentID="/external/audio/albums/484" restricted="1"><upnp:class>object.item.audioItem.musicTrack</upnp:class><dc:title>03-Miss Murder.complete</dc:title><dc:creator>AFI</dc:creator><upnp:artist>AFI</upnp:artist><upnp:albumArtURI>http://192.168.1.3:57645/external/audio/albums/484.jpg</upnp:albumArtURI><upnp:genre>Rock</upnp:genre><dc:date>2006-01-01</dc:date><upnp:album>&lt;unknown&gt;</upnp:album><upnp:originalTrackNumber>3</upnp:originalTrackNumber><res protocolInfo="http-get:*:audio/mpeg:*" bitrate="24000" size="4961736" duration="0:03:26.000">http://192.168.1.3:57645/external/audio/media/39883.mp3</res></item></DIDL-Lite></CurrentURIMetaData></u:SetAVTransportURI></s:Body></s:Envelope>
- // metadata = parser.generate(didl);
+ metadata = parser.generate(didl);
} catch(Exception e) {
Log.w(TAG, "Metadata generation failed", e);
}
|