How can I open a udp multicast video stream on android ?
I tried this code:
public class androidActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView videoView = (VideoView) findViewById(R.id.videoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse("udp://224.1.1.1:1234");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
}
}
but it doesn't work.
Android doesnt support UDP for audio and video playback.
see http://developer.android.com/guide/appendix/media-formats.html
You can use RTP over UDP.
This is with RTSP setup via TCP.
I do this with stock android rom, no third party apps required.
Stagefright framework.
Related
I have already seen most of the questions here but none of them helps.
Following is Streaming url it works perfectly on VLC and browser but it can't be played in android app.
Here is my code
public class VideoDemo extends Activity {
private VideoView video;
private MediaController ctlr;
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.main);
/* File clip = new File(Environment.getExternalStorageDirectory(),
"90.mp4");*/
/* if (clip.exists()) {*/
video = (VideoView) findViewById(R.id.video);
//video.setVideoPath(clip.getAbsolutePath());
video.setVideoURI(Uri.parse("http://103.50.152.102:9096/LubrizolWebPrj/service/getEnqVideo/90"));
video.requestFocus();
video.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mediaPlayer) {
video.start();
}
});
//}
}
}
MP4 is just a container - the video and audio stream inside it will both be encoded in different formats.
Android natively only supports certain types of formats. There is a list here:
http://developer.android.com/guide/appendix/media-formats.html
Make sure the video and audio encoding type is supported. Just because it says "mp4" doesn't automatically mean it should be playable.
Though if your format is not supported, Try using YoutubeVideoView
I have successfully stream ip camera on an android phone using rtsp using this code:
public class MainActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView video= (VideoView) findViewById(R.id.videoview);
String viewSource = "rtsp://192.168.1.........";
video.setVideoURI(Uri.parse(viewSource));
video.setMediaController(new MediaController(this));
video.requestFocus();
video.start();
}
}
My question is that is it possible to manipulate videoview on android using boofcv which is using ip camera? Because on boofcv samples it is using a built in camera on android phone. If someone is kind here can help me please.
I want to play YouTube videos on Android without using YouTube app. It should play with Android player. We have tried using YouTube app, but we need to play YouTube videos directly with Android player, not using YouTube application.
Is it possible? If it is, how to do it?
try this.
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView videoView = (VideoView) findViewById(R.id.VideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
// Set video link (mp4 format )
Uri video = Uri.parse("your url in rtsp format");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
}
Its simple just create video view then add a new media controller to it, set the video URL in the video view and start the video it will work.
Add the below Code into your MainActivity.java file.
#Override
protected void onCreate(Bundle savedInstanceState)
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
try {
setContentView(R.layout.videodisplay);
String link="http://www.youtube.com/watch?v=JSnB06um5r4";
VideoView videoView = (VideoView) findViewById(R.id.VideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse(link);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
} catch (Exception e) {
// TODO: handle exception
Toast.makeText(this, "Error connecting", Toast.LENGTH_SHORT).show();
}
}
You better try it on offline file to make sure that the video viewer is working fine (the video is compatible with device) then play it online
Am I missing something? Once I play a video using videoview, I cannot see the current time of the video on the media controller. (Running app on a ICS device, there is no time; however on a Honeycomb device there is time)
Code:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView videoView = (VideoView) findViewById(R.id.videoView);
// Use a media controller so that you can scroll the video contents
// and also to pause, start the video.
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView
.setVideoURI(Uri
.parse("rtsp://v6.cache5.c.youtube.com/CiILENy73wIaGQmCZld_oqDeJhMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"));
videoView.start();
}
Actually I noticed the time is there but it's so dim and I cannot see it. Is there any way that I can change the theme of the media controller?
The answer is kind of general to all of the controllers such a mediacontroller, dialog, toast, etc.
you can use ContextThemeWrapper:
instead of:
MediaController mediaController = new MediaController(this);
you can use:
MediaController mediaController = new MediaController(new ContextThemeWrapper(this,R.style.CustomTheme));
what's the problem there, I have uploaded this video to server, but now its not playing, but its playing if i put this video on sdcard which is commented
public class VideoPlayerActivity extends Activity {
/** Called when the activity is first created. */
private MediaController mc;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView vd = (VideoView) findViewById(R.id.VideoView);
mc = new MediaController(this);
vd.setMediaController(mc);
Toast.makeText(this, "Video Player Started", 20).show();
//vd.setVideoPath("sdcard/video/abc.mp4");
vd.setVideoURI(Uri.parse("http://www.primesquad.com/future.mp4"));
vd.start();
}
}
streaming video differ from playing it from sdCard as you see in Android Supported Media Formats there is restrictions for streaming that don't apply when playing video.
I faced this problem with videos stream normally in HTC Desire but refuse to stream with Motorola droid