I have troubled in playing a video that is not supported by hardware I want to create a simple video player that can play any video even it is not supported by hardware. I like the way how mx player did it. Can any one help me how to play a video like in MX player. I have this basic syntax but it only plays hardware supported videos. Here's my code
VideoView videoView = (VideoView) findViewById(R.id.videoView1);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri uri = uri = Uri.parse("android.resource://" + getPackageName() + "/"
+ R.raw.videointro);
videoView.setMediaController(mediaController);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();
You need to write intent and for that please pass the video url. Then android will identify apps which will able to play video then you need to pick/select one.
Related
Video auto play I want when user click on play button the video play.
VideoView videoView =(VideoView)findViewById(R.id.video_view);
MediaController mediaController= new MediaController(this);
mediaController.setAnchorView(videoView);
Uri uri=Uri.parse(selectedItem.getTrailerLink());
videoView.setMediaController(mediaController);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();
That's pretty simple: don't call start() right away.
Move that to the onClick method for the button, and you're good to go
I have video that is locally stored in assets folder. Here is my code. I am getting error cannot play video. It is .mp4 file. It plays perfectly on my macbook.
Uri video = Uri.parse("file:///android_asset/video");
Intent intent = new Intent(Intent.ACTION_VIEW, video)
intent.setDataAndType(video, "video/*");
startActivity(Intent.createChooser(intent, "Play Video"));
I have also placing it in raw folder, In this case I am not getting ActiviyNotFoundException
Uri video = Uri.parse("file:///android.resource://" + getActivity().getPackageName() + "/" + R.raw.video);
The assets directory is private to your application; other applications cannot access it.
You will either need to provide access to the file using a FileProvider, or copy the file to a directory that other applications can access.
If you want to play from sdcard then the try this.
Uri vidFile = Uri.parse("link");
VideoView videoView = (VideoView) findViewById(R.id.VideoView);
videoView.setVideoPath(path);
videoView.setMediaController(new MediaController(this));
videoView.start();
path can also be retrieved by MediaStore.Video.Media.DATA or you can type the path as /sdcard/videos
Also have a look at this tutorial
Creating an app. I want to have the app play video from my sdcard, without having to change the code every time. I want to be able to choose from any video on my phone, is this possible and if it is would you mind sharing code.
this is what i have
setContentView(R.layout.activity_play);
VideoView videoView=(VideoView)findViewById(R.id.videoView1);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
//Uri video = Uri.parse(Environment.getExternalStorageDirectory().getAbsolutePath()+"filename");
Uri video =Uri.parse("sdcard/KVID0023.mp4");
videoView.setVideoURI(video);
videoView.setMediaController(mediaController);
videoView.start();
Hi My Question is want to disable or not to show the video controls if i use ACTION_VIEW for any videos. Do i need to specify any extras for Intent or is there any proper way to achieve this
below is the code for reference
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(appnamesArray[arg2]));
Any Sample links or code helps me a lot
Thanks in Advance
EDIT:
As i understood that action_view starts the default player or user selected player so the controls goes to player and intent has no control to hide it for that i used videoview to show the video from url
VideoView videoView = (VideoView) new VideoView(getApplicationContext());
MediaController mediaController = new MediaController(MainActivity.this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse(appnamesArray[arg2]);
videoView.setMediaController(null);
videoView.setVideoURI(video);
videoView.start();
setContentView(videoView);
please update me if any one can able to succeed this by doing the ACTION_VIEW itself
If you use the view intent it will have option to open video in all the players that support it. So even if some of the players support hiding controls other might not.
Best solution is to have your own video view.
im trying to play a video in VideoView on an android application.
the question is how do i fetch the correct link to the video from youtube and not just the webpage?
setContentView(R.layout.videopopup);
VideoView vv = (VideoView)findViewById(R.id.videoElem);
MediaController mc = new MediaController(this);
mc.setEnabled(true);
mc.show(0);
vv.setMediaController(mc);
vv.setVideoURI(Uri.parse("http://www.youtube.com/v/oFL2rszPmmU?version=3&feature=player_detailpage"));
vv.requestFocus();
vv.showContextMenu();
vv.start();
in this link: Video View not playing youtube video
Evgeny Nacu explains which link it should be, but not how to retrieve it from a given youtube page.
Simple way to play video using default youtube app:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(your youtube url);
Youtube app will do everything. You need not do anything.
and if that doesn't solve, use webview instead of videoview in your code