Added support for local external video files

This commit is contained in:
daniel oeh 2013-02-28 12:38:56 +01:00
parent dcbf334bad
commit 248467d840
3 changed files with 44 additions and 6 deletions

View File

@ -326,6 +326,15 @@
android:name=".activity.VideoplayerActivity" android:name=".activity.VideoplayerActivity"
android:configChanges="keyboardHidden|orientation" android:configChanges="keyboardHidden|orientation"
android:screenOrientation="landscape" > android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:mimeType="video/*" />
</intent-filter>
</activity> </activity>
<activity <activity
android:name=".activity.PlaybackHistoryActivity" android:name=".activity.PlaybackHistoryActivity"

View File

@ -19,9 +19,11 @@ import com.actionbarsherlock.view.Window;
import de.danoeh.antennapod.AppConfig; import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.feed.MediaType;
import de.danoeh.antennapod.preferences.UserPreferences; import de.danoeh.antennapod.preferences.UserPreferences;
import de.danoeh.antennapod.service.PlaybackService; import de.danoeh.antennapod.service.PlaybackService;
import de.danoeh.antennapod.service.PlayerStatus; import de.danoeh.antennapod.service.PlayerStatus;
import de.danoeh.antennapod.util.playback.ExternalMedia;
import de.danoeh.antennapod.util.playback.Playable; import de.danoeh.antennapod.util.playback.Playable;
/** Activity for playing audio files. */ /** Activity for playing audio files. */
@ -54,14 +56,35 @@ public class VideoplayerActivity extends MediaplayerActivity implements
} }
} }
@Override
protected void onResume() {
super.onResume();
if (getIntent().getAction() != null
&& getIntent().getAction().equals(Intent.ACTION_VIEW)) {
Intent intent = getIntent();
if (AppConfig.DEBUG)
Log.d(TAG, "Received VIEW intent: "
+ intent.getData().getPath());
ExternalMedia media = new ExternalMedia(intent.getData().getPath(),
MediaType.VIDEO);
Intent launchIntent = new Intent(this, PlaybackService.class);
launchIntent.putExtra(PlaybackService.EXTRA_PLAYABLE, media);
launchIntent.putExtra(PlaybackService.EXTRA_START_WHEN_PREPARED,
true);
launchIntent.putExtra(PlaybackService.EXTRA_SHOULD_STREAM, false);
launchIntent.putExtra(PlaybackService.EXTRA_PREPARE_IMMEDIATELY,
true);
startService(launchIntent);
}
}
@Override @Override
protected void loadMediaInfo() { protected void loadMediaInfo() {
super.loadMediaInfo(); super.loadMediaInfo();
Playable media = controller.getMedia(); Playable media = controller.getMedia();
if (media != null) { if (media != null) {
getSupportActionBar().setSubtitle(media.getEpisodeTitle()); getSupportActionBar().setSubtitle(media.getEpisodeTitle());
getSupportActionBar() getSupportActionBar().setTitle(media.getFeedTitle());
.setTitle(media.getFeedTitle());
} }
} }

View File

@ -67,7 +67,10 @@ public interface Playable extends Parcelable {
/** Return position of object or 0 if position is unknown. */ /** Return position of object or 0 if position is unknown. */
public int getPosition(); public int getPosition();
/** Returns the type of media. */ /**
* Returns the type of media. This method should return the correct value
* BEFORE loadMetadata() is called.
*/
public MediaType getMediaType(); public MediaType getMediaType();
/** /**
@ -151,11 +154,14 @@ public interface Playable extends Parcelable {
} }
break; break;
case ExternalMedia.PLAYABLE_TYPE_EXTERNAL_MEDIA: case ExternalMedia.PLAYABLE_TYPE_EXTERNAL_MEDIA:
String source = pref.getString(ExternalMedia.PREF_SOURCE_URL, null); String source = pref.getString(ExternalMedia.PREF_SOURCE_URL,
String mediaType = pref.getString(ExternalMedia.PREF_MEDIA_TYPE, null); null);
String mediaType = pref.getString(
ExternalMedia.PREF_MEDIA_TYPE, null);
if (source != null && mediaType != null) { if (source != null && mediaType != null) {
int position = pref.getInt(ExternalMedia.PREF_POSITION, 0); int position = pref.getInt(ExternalMedia.PREF_POSITION, 0);
return new ExternalMedia(source,MediaType.valueOf(mediaType), position); return new ExternalMedia(source,
MediaType.valueOf(mediaType), position);
} }
break; break;
} }