From d39bd6831bea56b2e93f98107d630aa6d9056fdf Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Tue, 25 Sep 2012 12:59:47 +0200 Subject: [PATCH] Added support for application/ogg MIME type --- .../antennapod/adapter/FeedItemlistAdapter.java | 8 ++++---- src/de/danoeh/antennapod/feed/FeedMedia.java | 16 ++++++++++++++++ src/de/danoeh/antennapod/feed/MediaType.java | 5 +++++ .../antennapod/service/PlaybackService.java | 13 ++++++++----- .../syndication/namespace/rss20/NSRSS20.java | 2 +- 5 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 src/de/danoeh/antennapod/feed/MediaType.java diff --git a/src/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java b/src/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java index 403204eaf..050d7b493 100644 --- a/src/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java +++ b/src/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java @@ -20,6 +20,7 @@ import de.danoeh.antennapod.PodcastApp; import de.danoeh.antennapod.R; import de.danoeh.antennapod.feed.FeedItem; import de.danoeh.antennapod.feed.FeedManager; +import de.danoeh.antennapod.feed.MediaType; import de.danoeh.antennapod.storage.DownloadRequester; import de.danoeh.antennapod.util.Converter; import de.danoeh.antennapod.util.EpisodeFilter; @@ -135,11 +136,10 @@ public class FeedItemlistAdapter extends ArrayAdapter { holder.downloading.setVisibility(View.GONE); } - String type = item.getMedia().getMime_type(); - - if (type.startsWith("audio")) { + MediaType mediaType = item.getMedia().getMediaType(); + if (mediaType == MediaType.AUDIO) { holder.type.setImageResource(R.drawable.type_audio); - } else if (type.startsWith("video")) { + } else if (mediaType == MediaType.VIDEO) { holder.type.setImageResource(R.drawable.type_video); } else { holder.type.setImageBitmap(null); diff --git a/src/de/danoeh/antennapod/feed/FeedMedia.java b/src/de/danoeh/antennapod/feed/FeedMedia.java index ce5f3e176..36f345812 100644 --- a/src/de/danoeh/antennapod/feed/FeedMedia.java +++ b/src/de/danoeh/antennapod/feed/FeedMedia.java @@ -45,6 +45,22 @@ public class FeedMedia extends FeedFile { } } + /** Uses mimetype to determine the type of media. */ + public MediaType getMediaType() { + if (mime_type == null || mime_type.isEmpty()) { + return MediaType.UNKNOWN; + } else { + if (mime_type.startsWith("audio")) { + return MediaType.AUDIO; + } else if (mime_type.startsWith("video")) { + return MediaType.VIDEO; + } else if (mime_type.equals("application/ogg")) { + return MediaType.AUDIO; + } + } + return MediaType.UNKNOWN; + } + @Override public int getTypeAsInt() { return FEEDFILETYPE_FEEDMEDIA; diff --git a/src/de/danoeh/antennapod/feed/MediaType.java b/src/de/danoeh/antennapod/feed/MediaType.java new file mode 100644 index 000000000..324d0a221 --- /dev/null +++ b/src/de/danoeh/antennapod/feed/MediaType.java @@ -0,0 +1,5 @@ +package de.danoeh.antennapod.feed; + +public enum MediaType { + AUDIO, VIDEO, UNKNOWN +} diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java index 990d499b4..d46e6c153 100644 --- a/src/de/danoeh/antennapod/service/PlaybackService.java +++ b/src/de/danoeh/antennapod/service/PlaybackService.java @@ -43,6 +43,7 @@ import de.danoeh.antennapod.feed.Feed; import de.danoeh.antennapod.feed.FeedItem; import de.danoeh.antennapod.feed.FeedManager; import de.danoeh.antennapod.feed.FeedMedia; +import de.danoeh.antennapod.feed.MediaType; import de.danoeh.antennapod.receiver.MediaButtonReceiver; import de.danoeh.antennapod.receiver.PlayerWidget; import de.danoeh.antennapod.util.ChapterUtils; @@ -184,7 +185,8 @@ public class PlaybackService extends Service { */ public static Intent getPlayerActivityIntent(Context context, FeedMedia media) { - if (media.getMime_type().startsWith("video")) { + MediaType mt = media.getMediaType(); + if (mt == MediaType.VIDEO) { return new Intent(context, VideoplayerActivity.class); } else { return new Intent(context, AudioplayerActivity.class); @@ -475,7 +477,8 @@ public class PlaybackService extends Service { if (AppConfig.DEBUG) Log.d(TAG, "Setting up media player"); try { - if (media.getMime_type().startsWith("audio")) { + MediaType mediaType = media.getMediaType(); + if (mediaType == MediaType.AUDIO) { if (AppConfig.DEBUG) Log.d(TAG, "Mime type is audio"); playingVideo = false; @@ -488,7 +491,7 @@ public class PlaybackService extends Service { setStatus(PlayerStatus.PREPARING); player.prepare(); } - } else if (media.getMime_type().startsWith("video")) { + } else if (mediaType == MediaType.VIDEO) { if (AppConfig.DEBUG) Log.d(TAG, "Mime type is video"); playingVideo = true; @@ -660,10 +663,10 @@ public class PlaybackService extends Service { stopWidgetUpdater(); } int notificationCode = 0; - if (media.getMime_type().startsWith("audio")) { + if (media.getMediaType() == MediaType.AUDIO) { notificationCode = EXTRA_CODE_AUDIO; playingVideo = false; - } else if (media.getMime_type().startsWith("video")) { + } else if (media.getMediaType() == MediaType.VIDEO) { notificationCode = EXTRA_CODE_VIDEO; } resetVideoSurface(); diff --git a/src/de/danoeh/antennapod/syndication/namespace/rss20/NSRSS20.java b/src/de/danoeh/antennapod/syndication/namespace/rss20/NSRSS20.java index 2d4e5fcde..86369acf2 100644 --- a/src/de/danoeh/antennapod/syndication/namespace/rss20/NSRSS20.java +++ b/src/de/danoeh/antennapod/syndication/namespace/rss20/NSRSS20.java @@ -39,7 +39,7 @@ public class NSRSS20 extends Namespace { public final static String ENC_LEN = "length"; public final static String ENC_TYPE = "type"; - public final static String VALID_MIMETYPE = "audio/.*" + "|" + "video/.*"; + public final static String VALID_MIMETYPE = "audio/.*" + "|" + "video/.*" + "|" + "application/ogg"; @Override public SyndElement handleElementStart(String localName, HandlerState state,