Register tutorial 5 as a media player, so other applications (including browsers) can pass URIs to us. Unfortunately, the complete list of supported protocols and file extensions has to be provided, as Android does not seem to infer MIME types from file names.

This commit is contained in:
Xavi Artigas 2012-11-05 18:41:49 +01:00
parent fe3c684e90
commit 73ca70339c
2 changed files with 50 additions and 1 deletions

View file

@ -19,11 +19,47 @@
<activity <activity
android:name=".Tutorial5" android:name=".Tutorial5"
android:label="@string/app_name" > android:label="@string/app_name" >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
<!-- Local files whose type is known to Android -->
<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:mimeType="audio/*" />
<data android:mimeType="video/*" />
<data android:mimeType="image/*" />
</intent-filter>
<!-- Links from the browser. The list of extensions and supported
protocols can certainly be extended. -->
<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="http" />
<data android:pathPattern=".*\\.avi" />
<data android:pathPattern=".*\\.AVI" />
<data android:pathPattern=".*\\.mkv" />
<data android:pathPattern=".*\\.MKV" />
<data android:pathPattern=".*\\.webm" />
<data android:pathPattern=".*\\.WEBM" />
<data android:pathPattern=".*\\.ogv" />
<data android:pathPattern=".*\\.OGV" />
<data android:pathPattern=".*\\.mp4" />
<data android:pathPattern=".*\\.MP4" />
<data android:pathPattern=".*\\.qt" />
<data android:pathPattern=".*\\.QT" />
</intent-filter>
</activity> </activity>
<activity <activity
android:name="com.lamerman.FileDialog" android:name="com.lamerman.FileDialog"

View file

@ -118,7 +118,20 @@ public class Tutorial5 extends Activity implements SurfaceHolder.Callback, OnSee
} else { } else {
is_playing_desired = false; is_playing_desired = false;
position = duration = 0; position = duration = 0;
Intent intent = getIntent();
android.net.Uri uri = intent.getData();
if (uri == null)
mediaUri = defaultMediaUri; mediaUri = defaultMediaUri;
else {
Log.i ("GStreamer", "Received URI: " + uri);
if (uri.getScheme().equals("content")) {
android.database.Cursor cursor = getContentResolver().query(uri, null, null, null, null);
cursor.moveToFirst();
mediaUri = "file://" + cursor.getString(cursor.getColumnIndex(android.provider.MediaStore.Video.Media.DATA));
cursor.close();
} else
mediaUri = uri.toString();
}
Log.i ("GStreamer", "Activity created with no saved state:"); Log.i ("GStreamer", "Activity created with no saved state:");
} }
is_local_media = false; is_local_media = false;