Android screen toggle to continue playing video

Source: Internet
Author: User

We just need to re-onsaveinstancestate the method and remember the parameters we want to record.

Package Com.bawei.day07_videoview;import Android.os.bundle;import Android.os.environment;import Android.app.activity;import Android.view.menu;import Android.view.view;import Android.widget.MediaController; Import Android.widget.textview;import Android.widget.VideoView;PublicClassMainactivity extends Activity {PrivateVideoview Videoview; @OverrideProtectedvoidOnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); Videoview =(Videoview) Findviewbyid (R.id.video);//To get the SD card path of String path =Environment.getexternalstoragedirectory (). GetPath (); Videoview.setvideopath (path +"/xiao.3gp");//Player Mediacontroller Controller =New Mediacontroller (mainactivity.This); Videoview.setmediacontroller (Controller); Controller.setmediaplayer (Videoview); Videoview.start ();//Continue playback when horizontal screenif (savedinstancestate! =Null) {//Get Progressint ss = Savedinstancestate.getint ( "aa" ); // then play protected void  Onsaveinstancestate (Bundle outstate) {// TODO auto-generated method Stub Super.onsaveinstancestate (outstate); // record the current playback progress Outstate.putint ( " aa 

Android screen toggle to continue playing video

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.