Loosing buffer streaming in VideoView

All your problems with Audio, Video and Images.

Loosing buffer streaming in VideoView

Postby benuch » Fri Aug 20, 2010 5:17 am

Hello,

This is my fisrt topic, for my fisrt android application.

I play a video uri in a videoview. All work fine, except a point:
When I quit the videoview with the home button and i come back to the application. The video has loose the buffer and the position of play and start from the beginning of the video.

It was a clear problems for me, because the video during 15 min and the user must be able to quit and come back to video during this time.

The code to start videoview is very simple.
Code: Select all
super.onCreate(savedInstanceState);
      Log.d("ASI","video_Oncreate");
      setContentView(R.layout.video);

      // Récupération de la listview créée dans le fichier main.xml
      // mywebview = (WebView) this.findViewById(R.id.WebViewperso);
      video = (VideoView) findViewById(R.id.myvideo);
      video.setMediaController(new MediaController(this));
      video.setVideoURI(Uri.parse(url_ok));
      video.requestFocus();
      if (video.isPlaying()) {
         video.pause();
         video.stopPlayback();
      }
      video.start();


I'm alone to have this problem? Because I don't find something about this in the web.

Thanks you for you help, and sorry for me english
benuch
Freshman
Freshman
 
Posts: 2
Joined: Fri Aug 20, 2010 5:04 am

Top

Re: Loosing buffer streaming in VideoView

Postby blundell » Fri Aug 20, 2010 9:35 am

Read up on the Activity lifecycle
http://developer.android.com/guide/topi ... ntals.html
http://developer.android.com/reference/ ... ivity.html

Then read out how to save state when you activity is not in the front:
http://stackoverflow.com/questions/1517 ... ions-state

You basically want to override onPause save the position of where you are in the video
then override onResume and restart the video from this position
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: Loosing buffer streaming in VideoView

Postby benuch » Fri Aug 20, 2010 6:15 pm

Thanks for you response.

I'm trying it before to save the position, but this doesn't save the buffer. How can do conserved the buffer? And more interesting, that the vuffer continued to progress during the application are not in foreground.

May be start the videoview or mediaplayer associated to it in on another thread or in a service?

What is the best way to do that?

thanks a lot
benuch
Freshman
Freshman
 
Posts: 2
Joined: Fri Aug 20, 2010 5:04 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 19 guests