ashi
ashi

Reputation: 63

Sorry, the video cannot be played

I have a video file in my local server. I am feeding my android code with the URL for the video file. I have the video file in the video folder in Htdocs folder. I have looked up same questions on stackoverflow, but couldn't find a solution to this. Please help. Here's the code..

public class WatchActivity extends Activity {

String SrcPath = "http://localhost/video/Coldplay - In My Place.mp4";

   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main);
       VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview);
       myVideoView.setVideoURI(Uri.parse(SrcPath));
       myVideoView.setMediaController(new MediaController(this));
       myVideoView.requestFocus();
       myVideoView.start();
   }
}

and here's the logcat for this

10-06 12:02:11.473: D/MediaPlayer(332): Couldn't open file on client side, trying server side
10-06 12:02:11.523: E/MediaPlayer(332): error (1, -111)
10-06 12:02:11.723: E/MediaPlayer(332): Error (1,-111)
10-06 12:02:11.723: D/VideoView(332): Error: 1,-111
10-06 12:02:12.083: D/dalvikvm(332): GC_EXTERNAL_ALLOC freed 65K, 52% free 2609K/5379K, external 1813K/2137K, paused 50ms

Upvotes: 1

Views: 1703

Answers (1)

Chirag
Chirag

Reputation: 56935

First your link is wrong . Try with 10.0.2.2 instead of localhost .

Please try with .3gp Video file .

Try with below link . http://daily3gp.com/vids/747.3gp

Add Internet Permission in Manifest file.

<uses-permission android:name="android.permission.INTERNET"/>

Edit :

VideoView videoView = (VideoView)this.findViewById(R.id.videoView);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
videoView.setMediaController(mc);
videoView.setVideoURI(Uri.parse("http://hermes.sprc.samsung.pl/widget/tmp/testh.3gp"));

videoView.requestFocus();
videoView.start();

Upvotes: 1

Related Questions