4

I have to play a video in my android app. The file is stored on a online file server

link is : http://view.vzaar.com/923037/video

I am unable to play this file using VideoView. I also tried to load this file into WebView but the WebView opens Web Browser and then the file starts playing.

Is there any way to play these kind of file directly into my app without downloading into device?

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
Vipul Purohit
  • 9,807
  • 6
  • 53
  • 76
  • Provided this is an MP4 file (which it seems like it is), you should be able to play it in VideoView. Show us your code, maybe we'll spot the problem then. – Aleks G Feb 21 '12 at 13:05
  • VideoView mVideoView = (VideoView) findViewById(R.id.vdoTest); mVideoView.setVideoPath("http://view.vzaar.com/923037/video"); mVideoView.setMediaController(new MediaController(this)); This is my code for VideoView – Vipul Purohit Feb 21 '12 at 13:32

2 Answers2

7

For your VideoView, the prpoblem is with setVideoPath method. You need to use setVideoURI instead to specify a streaming source:

VideoView mVideoView = (VideoView) findViewById(R.id.vdoTest);
mVideoView.setMediaController(new MediaController(this));
String viewSource ="http://view.vzaar.com/923037/video";
mVideoView.setVideoURI(Uri.parse(viewSource));

This should work, provided the video is encoded correctly: (AAC+H.264, baseline)

Aleks G
  • 56,435
  • 29
  • 168
  • 265
  • Thanks a lot Aleks. You solved my problem. Work like a charm. Just one more question, Can I show thumbnail of video? Thnx in advance – Vipul Purohit Feb 22 '12 at 04:51
1

write this html code and load it in webview:

<html><body><embed src="http://view.vzaar.com/923037/video" width="100%" height="100%"></embed></body></html>
Seshu Vinay
  • 13,560
  • 9
  • 60
  • 109