How to play video mp4 using intent from my android app? This is possible?

╄→尐↘猪︶ㄣ 提交于 2019-12-12 10:49:12

问题


I need to play a mp4 video in my app, bat I want to use intent. Is this possible?

private void startTrailer(){

            Uri contentUri = Uri.parse("android.resource://" + pkgName + "/" +R.raw.v01_homem_ferro_3);
    Intent intent = new Intent( Intent.ACTION_VIEW );
    intent.setDataAndType( contentUri, "video/mp4" );
    context.startActivity( intent );
}

Exception: No Activity found to handle Intent.


回答1:


Somebody had this issue before. Check these links and see if they give you a good starting point to solve the problem:

Android intent for playing video?

How to play a video (.mp4) from assets or raw folder with the video intent?




回答2:


Please try this, Here strMyVideo is my filepath,

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(strMyVideo));
intent.setDataAndType(Uri.parse(strMyVideo), "video/mp4");
activity.startActivity(intent);


来源:https://stackoverflow.com/questions/17476781/how-to-play-video-mp4-using-intent-from-my-android-app-this-is-possible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!