Using VideoView for streaming or progressive-download video
Asked Answered
Y

3

42

I'm confused about how VideoView can be used to play video: from a local file, as progressive download and streaming.

This example work for me (on 1.5 and 2.0 at least) by downloading the file and playing it locally.

But is it necessary to download the video before playing: is it possible to play video as progressive download, or by streaming, simply by using setVideoPath or setVideoURI, as in VideoViewDemo in the API samples?

The VideoViewDemo code suggests using setVideoURI for streaming, but I'm not clear what kind of URL I should be using. Does someone have an example URL for a video that can be streamed to the Android emulator using the VideoViewDemo code?

Can progressive download be used with VideoViewDemo? I get a 'sorry, this video cannot be played' message using setVideoPath with URLs that work fine with the blog example linked to above.(Is this a problem in the emulator? I've tried 1.5 and 2.0.)

I've found a lot of examples and documentation online but, so far, nothing that really answers this question.

Yacano answered 13/1, 2010 at 17:44 Comment(3)
There is a good tutorial here, which guides you step by step and lists known issues and limitationsBlake
@MosheKravchik - the link no longer works. Any update?Knickers
@Sam Dutton: Are you able to stream video progressively(parallel downloading and playing)? To check whether progressive streaming works with video, i am downloading half video and playing downloaded half video but this approach says same error as yours can't play this video. So how do we stream video in android progressively without using VideoView setVideoURI or setVideoPath?Gardener
K
20

is it possible to play video as progressive download, or by streaming, simply by using setVideoPath or setVideoURI, as in VideoViewDemo in the API samples?

It should. It certainly works with MediaPlayer, and VideoView is just a ~200 line wrapper around MediaPlayer and a SurfaceView.

The VideoViewDemo code suggests using setVideoURI for streaming, but I'm not clear what kind of URL I should be using.

http:// and rtsp:// can work, if the video was encoded properly.

Does someone have an example URL for a video that can be streamed to the Android emulator using the VideoViewDemo code?

This video works with MediaPlayer, except on the Nexus One.

EDIT: Actually, that link works with the Nexus One as well.

Kilogrammeter answered 13/1, 2010 at 18:38 Comment(3)
The following page has several mp4 files can be used as test URIs for Android video streaming: people.sc.fsu.edu/~jburkardt/data/mp4/mp4.htmlPolyphone
can you give me some url to play progressive download.In your link i am not able to find urlNecessitarianism
I have encoded the file to be streamable progressively from a URL. Check my answer at #2593316Sigler
B
2

It works for simple cases, but only when it is not required to make some custom preparations for requests to get a stream.

This tutorial shows an example of manual streaming emulation for an audio but it can be a little refactored to play video:

http://blog.pocketjourney.com/2008/04/04/tutorial-custom-media-streaming-for-androids-mediaplayer/

(be sure to use FileDescriptor when setting dataSource, the API was changed slightly from those times).

Bernadettebernadina answered 24/9, 2010 at 14:51 Comment(4)
I followed that blog and it works only for audio files. It doesn't work for video file, To check whether progressive streaming works or not i wrote a sample program where it will download only half video and start playing half downloaded video file, it gives error message saying can't play this video.Gardener
Same here. Outdated I guess.Fishplate
Link to blog.pocketjourney.com out of dateQuadragesima
The answer is itself hugely outdated. However, if you are OK with 7-year old code, here's the example how I used it at that time: github.com/shamansir/vimeoid/blob/master/apk/src/org/vimeoid/…Bernadettebernadina
I
-4

VideoView can only Stream 3gp videos but i recommend this code to stream your video

public void onCreate(Bundle savedInstanceState){
setContentView(R.layout.main);
String videourl = "http://something.com/blah.mp4";
Uri uri = Uri.parse(videourl);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setDataAndType(uri, "video/mp4");
startActivity(intent);
}

Or Click here to watch Android Video Streaming Tutorial.

Iodoform answered 1/6, 2013 at 17:31 Comment(1)
VideoView can support way more formats - developer.android.com/guide/appendix/media-formats.htmlWodge

© 2022 - 2024 — McMap. All rights reserved.