Playing RTSP links in Android - android

I have a list of video links where some are http:// and some are rtsp://.
So, I created a method that invokes the native view in android to play the video. it works well with http but it is failing for the rtsp. Actually, It is giving me an error that is not helping either knowing that rtps is a supported media format (http://developer.android.com/guide/appendix/media-formats.html)
String url = (String) v.getTag();
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
Uri data = Uri.parse(url);
intent.setDataAndType(data, "video/*");
startActivity(intent);
Any ideas?

RTSP is a communication protocol extremely affected by firewalls, the fact that http works fine and rtsp is not, means that your firewall might be blocking that content and the rtsp feed you are getting might be configured to use UDP, in order to make sure that you are getting the rtsp data properly you should change your router configuration to not block that info, remember that rtsp can use UDP or TCP as transport layers and gets affected by the security system accordingly.
Hope this helps.
Regards!

try this code :
VideoView videoView = (VideoView) findViewById(R.id.videoView1);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
mediaController.setMediaPlayer(videoView);
Uri video = Uri.parse("your_RTSP_link");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();

Related

how to play sdp file in android?

I am using following code to play video for .3gp format and it works fine but I am facing problem while playing .sdp url.
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("rtsp://stream.the.sk/live/musicbox/musicbox-3m.3gp"));
startActivity(intent);
I need to play rtsp://ss1c6.idc.mundu.tv:554/prf0/cid_29.sdp format but it not work. Please help me. I tried to play it with VLC and MX Player.
Try this code in onCreate function. It will work i think.
VideoView view=new VideoView(this);
setContentView(view);
view.setMediaController(mediaController);
view.setVideoURI(Uri.parse("rtsp://ss1c6.idc.mundu.tv:554/prf0/cid_29.sdp"));
view.start();

disabling video controls in ACTION_VIEW

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.

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

android: using default video player

I have an application that plays video files.
I have been using code for using Videoview and starting the Videoview manually to play video files. However, I just wanted to know if I can use the default media player or video player of android rather than creating or using the VideoView to play the file..
Please make comments if the question is not clear.
Thanks alot
Sure - just use an Intent with the file Uri.
File file = new File("fileUri");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "video/*");
startActivity(intent);

Categories

Resources