Here is my code, and when I run the app, it will display "Sorry this video cannot be played".
public class rtspActivity extends Activity {
Button btn;
VideoView v;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rtsp);
v=(VideoView)findViewById(R.id.vv);
v.setVideoURI(Uri.parse("rtsp://server.intelcast.tv:554/live/haditvfour1"));
}
}
You should start with
v.setMediaController(new MediaController(this));
v.requestFocus();
v.start();
Also, the url you're using might not be good. Try it in VLC or similar, to see if its actually there
Another problem can be the "server.intelcast.tv:554" part, try replacing this with a real ip adress with numbers, i've experinced this issue myself
Related
I'm doing an android app that plays video from live camera.
I can watch live, but it comes back 1.5 seconds.
We do not want.
I used standard settings:
public class MainActivity extends AppCompatActivity {
VideoView videoView;
String videoUrl = "rtsp://admin:admin#192.168.1.125/live/0/h264.sdp";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView = (VideoView) this.findViewById(R.id.rtspVideo);
RtspStream(videoUrl);
}
private void RtspStream(String rtspUrl) {
videoView.setVideoURI(Uri.parse(rtspUrl));
videoView.setZOrderOnTop(false);
videoView.requestFocus();
videoView.postInvalidateDelayed(0);
videoView.start();
}
}
I think it's about buffer.
How can I solve the problem of coming back?
how can the library or application settings be used?
I am able to record and able to upload that video to firebase from my android app but not being able to play or stream(whatever is possible) to videoview. I am actually trying to get in it the recycler view but since it didn't work trying something simpler.
I read many post here in stackoverflow and tried almost all of them but none worked.So posting new question.
My code are as follows:
VideoView video;
//String video_url = "http://file2.video9.in/english/movie/2014/x-men-_days_of_future_past/X-Men-%20Days%20of%20Future%20Past%20Trailer%20-%20[Webmusic.IN].3gp";//this one works if i use it
String video_url = "https://firebasestorage.googleapis.com/longidcharacters-video.mp4?alt=media&token=xxxxx";
//but this link from firebase does not work, i usually fetch it from online
ProgressDialog pd;
Button playButton;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_video);
video = (VideoView) findViewById(R.id.Videoview1);
playButton=(Button) findViewById(R.id.playButton1);
pd = new ProgressDialog(ShowVideoActivity.this);
pd.setMessage("Buffering video please wait...");
pd.show();
Uri uri = Uri.parse(video_url);
video.setVideoURI(uri);
video.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
//close the progress dialog when buffering is done
pd.dismiss();
}
});
playButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
video.start();
}
});
It says "cannot play this video". The format is mp4(recorded from camera). However, if I play that 3gp one(which is commented now),it works fine.
What can i do? Is there any player I can try? I am just trying to stream or play video that is uploaded to firebase storage.
There are so many posts on the same topic but no one is giving proper reason for this error, Could some one help me to solving this error.
My code is working fine for SDCARD videos. whenever I try to access it from url it throws this error.
W/MediaPlayer: Couldn't open file on client side; trying server side: java.io.FileNotFoundException: No content provider: http://download.itcuties.com/teaser/itcuties-teaser-480.mp4
E/MediaPlayer: error (1, -2147483648)
I tried several formats and several urls for everything i am getting the same error.
Internet permissions given.
Code:
public class MainActivity extends AppCompatActivity {
VideoView video1;
String url ="http://download.itcuties.com/teaser/itcuties-teaser-480.mp4";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
video1 = (VideoView) findViewById(R.id.video1);
video1.setVideoURI(Uri.parse(url));
video1.setMediaController(new MediaController(this));
video1.requestFocus();
Thread view1=new Thread(new Runnable() {
#Override
public void run() {
// TODO Auto-generated method stub
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_DISPLAY);
video1.start();
}
});
}
}
You just need to start your view1 thread. Your code loads the video but doesn't play it. Adding this will solve the issue.
view1.start();
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 am a beginner and I have two question.
Why does the video in the attached code is not running (get a message from the emulator that the application cannot run the video).
Can anyone please help me to understand how should I implement the onTouchEvent in order to capture a touch on the screen (don't care where on the screen) while a video is running.
Thanks in advance
Amihay
public class VidShow extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.videoscrn);
/*run the video*/
VideoView video = (VideoView) findViewById(R.id.video);
// Load and start the movie
video.setVideoPath("raw/samplevideo.3gp" );
video.start();
}
}
Extend VideoView and implement VideoView.onTouchEvent(..).