I am trying to stream to my Android Application from an IP Webcam over RTSP, the stream plays successfully via the VLC Android app, but I cannot replicate this in my own application.
if (mediaControls == null)
{
mediaControls = new MediaController(VideoActivity.this);
}
myVideoView = (VideoView) findViewById(R.id.stream);
myVideoView.setOnErrorListener(this);
progressDialog = new ProgressDialog(VideoActivity.this);
progressDialog.setTitle("Camera Stream");
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(false);
//progressDialog.show();
try
{
myVideoView.setMediaController(mediaControls);
myVideoView.setVideoURI(Uri.parse(videoSrc));
}
catch (Exception e)
{
Log.e("Error", e.getMessage());
e.printStackTrace();
}
myVideoView.requestFocus();
myVideoView.setOnPreparedListener(new OnPreparedListener()
{
// Close the progress bar and play the video
public void onPrepared(MediaPlayer mp)
{
//progressDialog.dismiss();
myVideoView.seekTo(position);
if (position == 0)
{
myVideoView.start();
}
else
{
myVideoView.pause();
}
}
});
The activity prompts a "Cannot Play This Video" dialog. According to the Desktop VLC client the stream is MJPG, 320x256, displaying at 320x240, in the decoded format "Planar 4:2:0 YUV full scale." According to the camera's data sheet it is at 30fps.
I have been able to play other RTSP streams with this code, but not the one I need.
I have been trying to figure out how to use libVLC but haven't had much luck so far. Can anyone help me to get this stream into something my application can use?
Related
i want play video stream Format m3u8 with Exoplayer and vitamio but fail.url stream in link enter link description here . Give me the solution .
Thank u
Code play exoplayer me :
try {
emVideoView.setOnPreparedListener(ExoActivity.this);
emVideoView.setVideoURI(Uri.parse("" + stream));
emVideoView.setOnErrorListener(new OnErrorListener() {
#Override
public boolean onError() {
return false;
}
});
} catch (Exception e) {
}
Our APP has to stream music from network source. My question is why the mediaplayer play well when I play music using http stream, but I always got ERROR(1,-1004) when I use https stream source to play in some devices. **Important:**It only got this ERROR(1,-1004) in some devices, such as Nexus5, Nexus7 and Asus Fonepad 7.
Here is a snippet :
String url ="http://10.0.0.45/O0$1$8I87308.mp3";
MediaPlayer myMediaPlayer = new MediaPlayer();
myMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
myMediaPlayer.setDataSource(url);
myMediaPlayer.prepareAsync(); // might take long! (for buffering, etc)
} catch (IOException e) {
Toast.makeText(this, "mp3 not found", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
//mp3 will be started after completion of preparing...
myMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer player) {
player.start();
System.out.println("onPrepared");
}
});
I'm trying to play an rtsp stream using MediaPlayer in android and the application seems to always become stuck on MediaPlayer.prepare();
The url is valid as I tested it using VLC on my desktop.
Any ideas why the application is not preparing the stream.
class InitializeService extends Thread {
#Override
public void run() {
try {
player.prepare();
Log.d("Play", "Player prepared");
} catch (IOException e) {
e.printStackTrace();
fallback();
} catch (IllegalStateException e) {
e.printStackTrace();
fallback();
}
}
}
The log statement is never reached.
Update 1:
Sorry I forgot to mention that the stream will always be in 3gp format. Here is a url rtsp://r2---sn-p5qlsu76.c.youtube.com/CiILENy73wIaGQnTXOVs7Kwo8xMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp
Your stream might not be of a format supported by Android.
Check http://developer.android.com/guide/appendix/media-formats.html to see if Android supports it.
Turns out it was android l that wasn't able to play the streams.
I am playing video from url then .mp4 in playing but .mov format is giving IOException
java.io.IOException: Prepare failed.: status=0x1
My code for playing video is,
private void playVideo() {
if (extras.getString("video_path").equals("VIDEO_URI")) {
showToast("Please, set the video URI in HelloAndroidActivity.java in onClick(View v) method");
} else {
new Thread(new Runnable() {
public void run() {
try {
player.setDataSource(extras.getString("video_path"));
player.setDisplay(holder);
player.prepare();
} catch (IllegalArgumentException e) {
showToast("Error while playing video");
Log.i(TAG, "========== IllegalArgumentException ===========");
e.printStackTrace();
} catch (IllegalStateException e) {
showToast("Error while playing video");
Log.i(TAG, "========== IllegalStateException ===========");
e.printStackTrace();
} catch (IOException e) {
showToast("Error while playing video. Please, check your network connection.");
Log.i(TAG, "========== IOException ===========");
e.printStackTrace();
}
}
}).start();
}
}
Any pointers?
Please visit the website vitamio.org or download VitamioDemo from github github.com/yixia/VitamioDemo
if you want to use Vitamio as your video player in an app, you need to download the Vitamio SDK from their website. Play around with the demo project and you'll understand how it works.
I have implemented the same and it works absolutely fine with me.
.mov files are not supported in android.
Check the Supported Media Formats on developers site.
I am working on an application that tries to display the video which is streaming on a webserver. I have the HTTP link for the video stream. To connect to the webserver I am connecting to a specific WIFI which enables me to access the video.
I have taken care of the WIFI connectivity. I am having a problem when I try to display the video on my app using VideoView. I used a tool which showed me that I was receiving data from the server. So my application is receiving the packets of data for the video but it is unable to display it.
The code is like this :
private VideoView videoView;
videoView = (VideoView)findViewById(R.id.VideoView_videoOnly);
....
....
//connect to the router
String ip = "http://192.168.2.250";
URL url = null;
try {
url = new URL(ip);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
URLConnection connection = null;
try {
connection = url.openConnection();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String vidLink = "http://XXXX:XXXX#192.168.2.250/axis-cgi/mjpg/video.cgi";
//set up video streaming
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
Uri video = Uri.parse(vidLink);
videoView.setMediaController(mc);
videoView.setVideoURI(video);
videoView.start();
}
}
XXXX:XXXX is the username and password to access the video stream
According to the URL you are using, one can guess, you are receiving the stream in the MJPEG format. MJPEG is not natively supported by Android.
You will have to break your stream into jpegs, then create a Bitmap from each jpeg, then display bitmaps one by one.