summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavi Artigas <xartigas@fluendo.com>2012-11-05 17:41:49 (GMT)
committerXavi Artigas <xartigas@fluendo.com>2012-11-05 17:41:49 (GMT)
commit73ca70339cc0307303c84d06b91d052ddbbee7ef (patch)
treecdc461b384383008a25d6fd883888b8836387157
parentfe3c684e9073dc4ea17a7f74ae536b87d6a4b758 (diff)
downloadgst-sdk-tutorials-73ca70339cc0307303c84d06b91d052ddbbee7ef.tar.gz
gst-sdk-tutorials-73ca70339cc0307303c84d06b91d052ddbbee7ef.tar.xz
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.
-rwxr-xr-xgst-sdk/tutorials/android-tutorial-5/AndroidManifest.xml36
-rw-r--r--gst-sdk/tutorials/android-tutorial-5/src/com/gst_sdk_tutorials/tutorial_5/Tutorial5.java15
2 files changed, 50 insertions, 1 deletions
diff --git a/gst-sdk/tutorials/android-tutorial-5/AndroidManifest.xml b/gst-sdk/tutorials/android-tutorial-5/AndroidManifest.xml
index fb57547..11b7f39 100755
--- a/gst-sdk/tutorials/android-tutorial-5/AndroidManifest.xml
+++ b/gst-sdk/tutorials/android-tutorial-5/AndroidManifest.xml
@@ -19,11 +19,47 @@
<activity
android:name=".Tutorial5"
android:label="@string/app_name" >
+
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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
android:name="com.lamerman.FileDialog"
diff --git a/gst-sdk/tutorials/android-tutorial-5/src/com/gst_sdk_tutorials/tutorial_5/Tutorial5.java b/gst-sdk/tutorials/android-tutorial-5/src/com/gst_sdk_tutorials/tutorial_5/Tutorial5.java
index a590b4b..621e246 100644
--- a/gst-sdk/tutorials/android-tutorial-5/src/com/gst_sdk_tutorials/tutorial_5/Tutorial5.java
+++ b/gst-sdk/tutorials/android-tutorial-5/src/com/gst_sdk_tutorials/tutorial_5/Tutorial5.java
@@ -118,7 +118,20 @@ public class Tutorial5 extends Activity implements SurfaceHolder.Callback, OnSee
} else {
is_playing_desired = false;
position = duration = 0;
- mediaUri = defaultMediaUri;
+ Intent intent = getIntent();
+ android.net.Uri uri = intent.getData();
+ if (uri == null)
+ 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:");
}
is_local_media = false;