Recording video with mediaplayer - android

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();

Related

Video auto play I want when user click on play button the video play

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

How to play video using software like on MX player?

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.

Android VideoView display my Video but Rotated

In my application I need to record a video, view the recorded video then submit it to the server.
Recording Video is working fine.. and the video saved to my android device..
When I go to another activity to view the video, the video displayed to me with different rotation (like if it was rotated by 90). while the video saved on my device is not rotated.
My Code:
captureVideoIntent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
captureVideoIntent.putExtra("android.intent.extra.durationLimit", 30);
startActivityForResult(captureVideoIntent, VIDEO_CAPTURED);
onActivityResult, I saved the video Uri
... mgr.videoFileUri = data.getData(); .....
Activity to Display the Video (with other fields):
video = (VideoView) findViewById(R.id.VideoView);
video.setVideoURI(mgr.videoFileUri);
video.setMediaController(new MediaController(this));
video.requestFocus();
video.start();

Android Capture Video and play

I want my application to Record a video and play on VideView in android. I am doing this for that.
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
context.startActivityForResult(takeVideoIntent, ACTION_TAKE_VIDEO);
// context is an Activity's context
And overriding onActivityResult() as
Uri mVideoUri = data.getData();
videoView.setVideoUri(mVideoUri);
videoView.setMediaController(new MediaController(this));
videoView.requestFocus();
But Its not playing the recorded video, I also tried by using
videoView.setVideoPath(mVideoUri.getPath());
instead of Uri, but nothing happened except one change that, it show this video cannot be played.
I fixed this issue, i just made a silly mistake that i didn't invoke videoView.start() Method.

how to fetch correct URL to video

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

Categories

Resources