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(..).
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?
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
I want to play four video in same activity in android is there any way to do it.
thank you.
Create more than one video view, and play different video in each one.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView video1 = (VideoView)findViewById(R.id.videoview1);
VideoView video2 = (VideoView)findViewById(R.id.videoview2);
// set paths and play each one
}
I am currently playing a video in andriod from the url http://daily3gp.com/vids/747.3gp
its working successfully.
But here i need to play that url through server, please let me know how to play.
Find the code below:
CODE
public class Activity3 extends Activity {
private VideoView videoView;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main2);
videoView = (VideoView)this.findViewById(R.id.videoView_surface_1);
MediaController mc = new MediaController(this);
videoView.setMediaController(mc);
videoView.setVideoURI(Uri.parse("http://daily3gp.com/vids/747.3gp"));
videoView.requestFocus();}}
Thanks for your Time!!
You have to call videoview.start() after this call only videoview will start playing video.
Hi all i've ran into another problems with VideoView.
Then video is playing, and I put device asleep, using hard button, onPause() is called. But it followed by:
03-17 11:26:33.779: WARN/ActivityManager(884): Activity pause timeout for HistoryRecord{4359f620 com.package/com.package.VideoViewActivity}
And then i have onStart()/onResume() again and Video starts playing. I've try to move code around onStart()/onStop() - doesn't seems to make difference.
sample code :
public class VideoViewActivity extends Activity {
private String path = "";
private VideoView mVideoView;
private static final String MEDIA_URL = "media_url";
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView)findViewById(R.id.surface_view);
path = getIntent().getStringExtra(MEDIA_URL);
}
#Override
public void onResume() {
super.onResume();
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
mVideoView.start();
}
#Override
public void onPause() {
super.onPause();
mVideoView.stopPlayback();
mVideoView.setMediaController(null);
}
}
Why is it happening? And how do I stop that?
It's not a greatest experience than you put your device to sleep and it starts playing video
OK, Looks like the behavior is related to activity lifecycle and the fact that VideoViewActivity is set to landscape in the manifest. Adding
android:configChanges="keyboardHidden|orientation"
for that activity
seems to fix the problem and then you put device to sleep only onPause() called vs before - all lifecycle methods were executed.
I'll do more testing to make sure it fixed...