开发者

How can I enable users to play video using my app?

开发者 https://www.devze.com 2023-04-04 11:00 出处:网络
Just spent a couple of hours last night developing a pretty sweet video player for Honeycomb, and now I\'d of course love for people to be able to use it.

Just spent a couple of hours last night developing a pretty sweet video player for Honeycomb, and now I'd of course love for people to be able to use it.

How can I make my application listen for / receive "video play broadcasts"?

I'm guessing it's got something to do with the manifest.xml file, but I was unable to find anything about it on the Android Developer site.

I've tried using the following without much success:

<receiver android:name=".VideoPlayer">
    <intent-fi开发者_如何学运维lter>
        <action android:name="android.intent.action.VIEW">
            <data android:mimeType="video/*" />
        </action>
    </intent-filter>
</receiver>


I eventually solved this one myself with the following code in my manifest.xml file:

    <!-- Video player -->
    <activity android:name=".VideoPlayer" android:label="@string/app_name"
        android:theme="@style/BlackHolo" android:screenOrientation="sensorLandscape">
        <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="rtsp" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="video/*" />
            <data android:mimeType="application/sdp" />
        </intent-filter>
        <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:mimeType="video/*" />
        </intent-filter>
    </activity>


Video players are usually implemented as activities. Hence, you would use an <activity> element for that action and MIME type, not a <receiver> element. You might also want to specify both the DEFAULT and BROWSABLE categories -- the latter would be needed for links clicked on in a Web browser.

0

精彩评论

暂无评论...
验证码 换一张
取 消