Saturday 15 May 2010

android:: how to add suitable delay during playing a video in VideoView -


I am a new kid for Android Currently, I am playing a video of URL in Android Video V. How do I add duplication to the video game via Android code? With the thread (3000) I sleep, I can only delay it 1 time but I want to delay video play after every 5 seconds.

Job: Status 1: For User 1 I have to add a duplication delay during video play; This means that the video will play for 5 seconds and then it will be almost near delays. 4-5 seconds In fact, I'm trying to create a situation that will show the viewer that there is some delay during video buffering.

Any solution.

Thanks

Private Zero Play Video () {

  try {final string path = "http: //daily3gp.com/vids/747.3gp "; If (path == null) path.length () == 0) {toast.makeText (CT Streaming. This, "File URL / Path is empty", Toast.LNNHT_LOG). Show (); } Else {** Thread.Sleep (3000); ** // If the path has not changed, then simply the Media Player Lodge. Start V (Tag, "Thread Sleep .... 3000 Ms."); If (path.equals (current) & amp; amp; mVideoView! = Null) {mVideoView.start (); MVideoView.requestFocus (); Return; } Current = path; Logs. I (tag, "PlayVideo () =" + path value in path); MVideoView.setVideoPath (getDataSource (path)); MVideoView.start (); MVideoView.requestFocus (); }   

}

// getDataSource method which will be used by playVideo ()

  throws private string getDataSource (string path) Is IOException {if URLUtil.isNetworkUrl (path)) {return path; } Else {url = url = new URL (path); URLConnection cn = url.openConnection (); Cn.connect (); InputStream stream = cn.getInputStream (); If (stream == empty) new runtime exception throw ("stream is empty"); File temporary = file. CreateTemplate File ("MediaPlayTM", "Data", this.getCacheDir ()); Temp.deleteOnExit (); String tempPath = temp.getAbsolutePath (); FileOutputStream Out = New FileOutputStream (temp); Byte Buff [] = New Byte [128]; Do {int numread = stream.read (buf); Logs. I (tag, "via buffer printing array:" + arrays.toString (buf)); If break (numread & lt; = 0); Out.written (buff, 0, hooks); } While (true); Try {stream.close (); } Hold (IOException pre) {log. A (tag, "error:" + east .getMessage (), east); } Return TampaPath; }}    

Try this code:

  handler H = new handler (Looper.getMainLooper ()); Runnable R = New Runnabal () {@ Override Public Wide Run () - // code, code run in UI, thread thread, dosoming (); }}; H.postDelayed (R, 2000); // - run after 2 seconds    

No comments:

Post a Comment