我正在制作视频播放器,当我分享视频并打开链接时,我的默认播放器上的播放不在我的应用中。如何在我的应用上打开该视频。
这是我的代码(在片段类中):
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT,
"Hey check out my app at: "+share_video);
sendIntent.setType("text/plain");
startActivity(sendIntent);
答案 0 :(得分:0)
试试这个: - 你可以使用createChooser作为你的意图,它会显示那些能够处理你意图的应用程序。
例如: -
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT,
"Hey check out my app at: "+share_video);
sendIntent.setType("text/plain");
Intent chooser = Intent.createChooser(sendIntent);
// Verify the intent will resolve to at least one activity
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(chooser);
}
答案 1 :(得分:0)
使用视频观看: 对于流式传输链接,您可以执行以下操作:
String LINK = "type_here_the_link";
VideoView mVideoView = (VideoView) findViewById(R.id.videoview);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
Uri video = Uri.parse(LINK);
mVideoView.setMediaController(mc);
mVideoView.setVideoURI(video);
mVideoView.start();
>or for local video u can do something like:
VideoView videoView =(VideoView)findViewById(R.id.videoView1);
//Creating MediaController
MediaController mediaController= new MediaController(this);
mediaController.setAnchorView(videoView);
//specify the location of media file
Uri uri=Uri.parse(Environment.getExternalStorageDirectory().getPath()+"/media/1.mp4");
//Setting MediaController and URI, then starting the videoView
videoView.setMediaController(mediaController);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();
> U can visit the link for more understanding:
> https://www.javatpoint.com/playing-video-in-android-example