luc*_*ucy 11 android media-player
如何从按钮单击打开远程视频文件URL以在内部MediaPlayer中播放而无需打开浏览器窗口?
视频播放正常,但它总是打开浏览器窗口1,这很烦人.
这就是我已经使用的,但是可以在没有应用程序首先打开浏览器窗口的情况下启动媒体播放器.
希望有人能提供帮助
谢谢露西
final Button button = (Button) findViewById(R.id.play);
button.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
// Perform action on click
Uri uri = Uri.parse("http://domain.com/videofile.mp4");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
}
Run Code Online (Sandbox Code Playgroud)
din*_*rma 21
试试这个:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(videoPath), "video/mp4");
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
Com*_*are 11
尝试将MIME类型添加到Intent.现在,您将路由到浏览器,它HTTP HEAD确定MIME类型,然后将其路由到正确的应用程序.如果您自己输入MIME类型,则应跳过浏览器步骤.
您需要在意图上设置videoUrl和 MIME 类型 ( video/mp4),即:
String videoUrl = "http://videosite/myvideo.mp4";
Intent playVideo = new Intent(Intent.ACTION_VIEW);
playVideo.setDataAndType(Uri.parse(videoUrl), "video/mp4");
startActivity(playVideo);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14288 次 |
| 最近记录: |