如何在android中使用intent播放流视频?

时间:2016-06-21 12:41:35

标签: android

这个用于打开玩家的弹出窗口。但如何播放视频文件与特定的播放器,如 MX播放器等..

 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
 intent.setDataAndType(Uri.parse(url), "video/*");

1 个答案:

答案 0 :(得分:4)

请参阅MX播放器API链接。

https://sites.google.com/site/mxvpen/api

/** Open another app.
 * @param context current Context, like Activity, App, or Service
 * @param packageName the full package name of the app to open
 * @return true if likely successful, false if unsuccessful
 */
public static boolean openApp(Context context, String packageName) {
    PackageManager manager = context.getPackageManager();
    try {
        Intent i = manager.getLaunchIntentForPackage(packageName);
        if (i == null) {
            return false;
            //throw new PackageManager.NameNotFoundException();
        }
        i.addCategory(Intent.CATEGORY_LAUNCHER);
        context.startActivity(i);
        return true;
    } catch (PackageManager.NameNotFoundException e) {
        return false;
    }
}

openApp(this, "com.mxtech.videoplayer.pro"); // Pro version of MX player
openApp(this, "com.mxtech.videoplayer.ad"); // free version of MX player
相关问题