我创建了自己的媒体播放器应用程序并安装在一个设备中。只要单击按钮,我就创建了另一个只有一个按钮的应用程序。我应该给出一个选择,在哪个玩家应该播放视频。
我的媒体播放器应用程序的清单文件:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/NoActionBar" >
<activity
android:name="com.example.player.MainPlayerActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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="rtsp" />
</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:scheme="https" />
<data android:scheme="content" />
<data android:scheme="file" />
<data android:mimeType="video/mpeg4" />
<data android:mimeType="video/mp4" />
<data android:mimeType="video/3gp" />
<data android:mimeType="video/3gpp" />
<data android:mimeType="video/3gpp2" />
<data android:mimeType="video/webm" />
<data android:mimeType="video/avi" />
<data android:mimeType="application/sdp" />
<data android:mimeType="video/x-ms-wmv" />
<data android:mimeType="video/x-msvideo" />
<data android:mimeType="video/mpeg" />
</intent-filter>
<intent-filter>
!-- HTTP live support -->
<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="audio/x-mpegurl" />
<data android:mimeType="audio/mpegurl" />
<data android:mimeType="application/vnd.apple.mpegurl" />
<data android:mimeType="application/x-mpegurl" />
</intent-filter>
</activity>
</application>
提出意图的示例代码:
public class MainActivityHsl extends Activity {
private String url = "/sdcard/vid.mp4";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_activity_hsl);
Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
playVideo(MainActivityHsl.this, Uri.parse("/sdcard/vid.mp4"), "SUKESH");
}
});
}
public void playVideo(Activity activity, Uri uri, String title) {
Intent intent = new Intent(Intent.ACTION_VIEW)
.setDataAndType(uri, "video/mp4");
intent.putExtra(Intent.EXTRA_TITLE, title);
activity.startActivity(intent);
}}
逻辑猫:
E/AndroidRuntime( 1552):android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512) E/AndroidRuntime( 1552):android.content.ActivityNotFoundException:在android.app.Instrumentation.execStartActivity(Instrumentation.java:1384) E/AndroidRuntime( 1552):在android.app.Activity.startActivityForResult(Activity.java:3190) E/AndroidRuntime( 1552):在android.app.Activity.startActivityForResult(Activity.java:3190)E/AndroidRuntime(1552):在android.app.Activity.startActivityForResult(Activity.java:3190)E/AndroidRuntime(1552)android.app.Activity.startActivity(Activity.java:3297) E/AndroidRuntime( 1552):at com.example.videohsltest.MainActivityHsl.playVideo(MainActivityHsl.java:54) E/AndroidRuntime( 1552):at com.example.videohsltest.MainActivityHsl$1.onClick(MainActivityHsl.java:30) E/AndroidRuntime( 1552):at android.view.View.performClick(View.java:3511) E/AndroidRuntime( 1552):at android.view.View.onKeyUp( android.widget.TextView.onKeyUp(TextView.java:5586) ) E/AndroidRuntime( 1552):在android.view.KeyEvent.dispatch(KeyEvent.java:2575) E/AndroidRuntime( 1552):在android.view.View.dispatchKeyEvent(View.java:5500) E/AndroidRuntime( 1552):在android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1246) E/AndroidRuntime( 1552):在android。view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1246) E/AndroidRuntime( 1552):at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1246) E/AndroidRuntime( 1552):at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1246) E/AndroidRuntime( 1552):at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1879) E/AndroidRuntime( 1552):at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1361) E/AndroidRuntime( 1552):在android.app.Activity.dispatchKeyEvent(Activity.java:2324) E/AndroidRuntime( 1552):at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1806) E/AndroidRuntime( 1552):at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3327) E/AndroidRuntime( 1552):at android.view.ViewRootImpl.handleFinishedEvent(ViewRootImpl.java:3300) E/AndroidRuntime( 1552):在android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2460) E/AndroidRuntime( 1552):at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 1552):at android.os.Looper.loop(Looper.java:137) E/AndroidRuntime( 1552):at android.app.ActivityThread.main(ActivityThread.java:4424) E/AndroidRuntime( 1552):at java.lang.reflect.Method.invokeNative(原生方法) E/AndroidRuntime( 1552年)):java.lang.reflect.Method.invoke(Method.java:511) E/AndroidRuntime( 1552):com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) E/AndroidRuntime( 1552):com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) E/AndroidRuntime( 1552):dalvik.system.NativeStart.main(原生方法) W/ActivityManager( 203):强制整理活动com.example.visual activity /..MainActivityHsl
请任何人帮助我摆脱这一点,我无法启动完整的行动使用对话框弹出。可能是什么原因。提前谢谢。
发布于 2013-04-04 09:53:54
海豚播放器就是这样做的。
<activity android:name="com.example.player.MainPlayerActivity"" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden"
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:mimeType="video/*" />
<data android:mimeType="application/x-quicktimeplayer*" />
<data android:mimeType="application/x-mpeg" />
<data android:mimeType="application/vnd.dvd*" />
<data android:mimeType="application/vnd.3gp*" />
<data android:mimeType="application/3gpp*" />
<data android:mimeType="application/vnd.rn-realmedia*" />
<data android:mimeType="application/mp4*" />
<data android:mimeType="application/mpeg*" />
<data android:mimeType="application/sdp" />
<data android:mimeType="application/vnd.wap.mms-message" />
<data android:pathPattern=".*mkv" />
<data android:pathPattern=".*MKV" />
<data android:pathPattern=".*flv" />
<data android:pathPattern=".*FLV" />
<data android:pathPattern=".*wmv" />
<data android:pathPattern=".*WMV" />
<data android:pathPattern=".*ts" />
<data android:pathPattern=".*TS" />
<data android:pathPattern=".*rm" />
<data android:pathPattern=".*RM" />
<data android:pathPattern=".*rmvb" />
<data android:pathPattern=".*RMVB" />
<data android:pathPattern=".*webm" />
<data android:pathPattern=".*WEBM" />
<data android:pathPattern=".*mov" />
<data android:pathPattern=".*MOV" />
<data android:pathPattern=".*mpg" />
<data android:pathPattern=".*MPG" />
<data android:pathPattern=".*dat" />
<data android:pathPattern=".*DAT" />
<data android:pathPattern=".*vstream" />
<data android:pathPattern=".*VSTREAM" />
<data android:pathPattern=".*mpeg" />
<data android:pathPattern=".*MPEG" />
<data android:pathPattern=".*f4v" />
<data android:pathPattern=".*F4V" />
<data android:pathPattern=".*avi" />
<data android:pathPattern=".*AVI" />
<data android:pathPattern=".*ogv" />
<data android:pathPattern=".*OGV" />
<data android:pathPattern=".*dv" />
<data android:pathPattern=".*DV" />
<data android:pathPattern=".*divx" />
<data android:pathPattern=".*DIVX" />
<data android:pathPattern=".*vob" />
<data android:pathPattern=".*VOB" />
<data android:pathPattern=".*asf" />
<data android:pathPattern=".*ASF" />
<data android:pathPattern=".*3gp" />
<data android:pathPattern=".*3GP" />
<data android:pathPattern=".*3gpp" />
<data android:pathPattern=".*3GPP" />
<data android:pathPattern=".*h264" />
<data android:pathPattern=".*H264" />
<data android:pathPattern=".*h261" />
<data android:pathPattern=".*H261" />
<data android:pathPattern=".*h263" />
<data android:pathPattern=".*H263" />
</intent-filter>
</activity>
您可以删除播放机不支持的不必要的媒体格式。
https://stackoverflow.com/questions/15807729
复制相似问题