2011-09-10 23 views
3

只是花了幾個小時,昨晚開發蜂窩是一個非常甜蜜的視頻播放器,現在我當然愛的人能夠使用它。如何讓用戶使用我的應用播放視頻?

我怎樣才能讓我的應用程序偵聽/接收「視頻播放廣播」?

我猜它得到的東西做的manifest.xml文件,但我無法找到它的Android開發者網站的任何東西。

我使用下面的沒有多少成功的嘗試:

<receiver android:name=".VideoPlayer"> 
    <intent-filter> 
     <action android:name="android.intent.action.VIEW"> 
      <data android:mimeType="video/*" /> 
     </action> 
    </intent-filter> 
</receiver> 

回答

7

我終於解決了這一個我用下面的代碼在我manifest.xml文件:

<!-- 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> 
+0

我用你的上面的代碼,但我的應用程序沒有顯示點擊一些視頻網址?我測試了這個網址http://km.support.apple.com/library/APPLE/APPLECARE_ALLGEOS/HT1211/sample_iTunes.mov請幫我解決它不是爲我工作的問題 –

+0

。 – berserk

+0

謝謝這工作 –

1

視頻播放器通常被實現爲活動。因此,你可以使用一個<activity>元素的行動和MIME類型,而不是一個<receiver>元素。您可能還需要同時指定DEFAULTBROWSABLE類別 - 後者將需要的鏈接在Web瀏覽器點擊。

+0

謝謝,剛剛發現:) –

+0

我用這個代碼在我的清單登記自己的活動:HTTP:// pastie .org/9257525但它不起作用。有任何想法嗎? – berserk

+0

@berserk:添加'DEFAULT'類別,如我的答案中所述。如果您對此主題有進一步的擔憂,請提出新的Stack Overflow問題。 – CommonsWare