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
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 this video url rtsp://someserver:port/live/001204A006F5.stream and wanted to play the same from android media player. I have written following code snippet but android is showing a dialog box with the msg "Can't play this video".
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);`
videoPlayer = (VideoView) findViewById(R.id.videoPlayer);
videoPlayer.setOnPreparedListener(this);
videoPlayer.setOnCompletionListener(this);
videoPlayer.setKeepScreenOn(true);
Uri uri = Uri.parse("rtsp://someserver:port/live/001204A006F5.stream");
videoPlayer.setVideoURI(uri);
}
/** This callback will be invoked when the file is ready to play */
public void onPrepared(MediaPlayer vp) {
if(videoPlayer.canSeekForward()) videoPlayer.seekTo(videoPlayer.getDuration()/5);
videoPlayer.start();
}
Am I doing something wrong? Or it is not possible to play that link with VideoView?
I m trying to play a video from SD card, I hav PUSH-ed a video into mnt/sdcard folder from DDMS view in eclipse.But the emulator screen shows blank without any error. Pls help.
public class Video extends Activity {
private MediaController mc;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
videoPlayer("mnt/sdcard","bikekid",true);
}
public void videoPlayer(String path, String fileName, boolean autoplay){
//get current window information, and set format, set it up differently, if you need some special effects
getWindow().setFormat(PixelFormat.TRANSLUCENT);
//the VideoView will hold the video
VideoView videoHolder = new VideoView(this);
//MediaController is the ui control howering above the video (just like in the default youtube player).
videoHolder.setMediaController(new MediaController(this));
//assing a video file to the video holder
videoHolder.setVideoURI(Uri.parse(path+"/"+fileName));
//get focus, before playing the video.
videoHolder.requestFocus();
if(autoplay){
videoHolder.start();
}
}
}/// end class
Use
.getAbsolutePath()
instead of "mnt/sdcard"
Edit:
use this
File file = new File(Environment.getExternalStorageDirectory(),"bikekid");
Uri mUri = Uri.fromFile(fie);
videoHolder.setVideoURI(mUri);
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.
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.