Android Development video playback call Setvideopath () method

Source: Internet
Author: User

When Setvideopath (), the bottom is this walk:

Setvideopath ()-->setvideouri ()-->openvideo ();

Openvideo () is only part of the Setvideouri (), and some of it is not written, below to see the specific contents of Openvideo:

1 Private voidOpenvideo () {2         if(MUri = =NULL|| Msurfaceholder = =NULL) {3             //Not playback just yet, would try again later4             return;5         }6         //we shouldn ' t clear the target State, because somebody might has7         //called Start () previously8Releasefalse);9 TenAudiomanager am =(Audiomanager) Mcontext.getsystemservice (context.audio_service); OneAm.requestaudiofocus (NULL, Audiomanager.stream_music, audiomanager.audiofocus_gain); A  -         Try { -Mmediaplayer =NewMediaPlayer (); the             //todo:create Subtitlecontroller in MediaPlayer, but we need -             //a context for the subtitle renderers -             FinalContext context =GetContext (); -             FinalSubtitlecontroller Controller =NewSubtitlecontroller ( + context, Mmediaplayer.getmediatimeprovider (), mmediaplayer); -Controller.registerrenderer (Newwebvttrenderer (context)); +Controller.registerrenderer (Newttmlrenderer (context)); AController.registerrenderer (Newcea708captionrenderer (context)); atController.registerrenderer (Newclosedcaptionrenderer (context)); -Mmediaplayer.setsubtitleanchor (Controller, This); -  -             if(Maudiosession! = 0) { - Mmediaplayer.setaudiosessionid (maudiosession); -}Else { inMaudiosession =Mmediaplayer.getaudiosessionid (); -             } to Mmediaplayer.setonpreparedlistener (mpreparedlistener); + Mmediaplayer.setonvideosizechangedlistener (msizechangedlistener); - Mmediaplayer.setoncompletionlistener (mcompletionlistener); the Mmediaplayer.setonerrorlistener (merrorlistener); * Mmediaplayer.setoninfolistener (minfolistener); $ Mmediaplayer.setonbufferingupdatelistener (mbufferingupdatelistener);Panax NotoginsengMcurrentbufferpercentage = 0; - Mmediaplayer.setdatasource (Mcontext, MUri, mheaders); the Mmediaplayer.setdisplay (msurfaceholder); + Mmediaplayer.setaudiostreamtype (audiomanager.stream_music); AMmediaplayer.setscreenonwhileplaying (true); the Mmediaplayer.prepareasync (); +  -              for(Pair<inputstream, mediaformat>pending:mpendingsubtitletracks) { $                 Try { $ Mmediaplayer.addsubtitlesource (Pending.first, pending.second); -}Catch(IllegalStateException e) { - Minfolistener.oninfo ( theMmediaplayer, Mediaplayer.media_info_unsupported_subtitle, 0); -                 }Wuyi             } the  -             //we don ' t set the target state here either, but preserve the Wu             //Target State is there before. -Mcurrentstate =state_preparing; About Attachmediacontroller (); $}Catch(IOException ex) { -LOG.W (TAG, "Unable to open content:" +MUri, ex); -Mcurrentstate =State_error; -Mtargetstate =State_error; AMerrorlistener.onerror (Mmediaplayer, Mediaplayer.media_error_unknown, 0); +             return; the}Catch(IllegalArgumentException ex) { -LOG.W (TAG, "Unable to open content:" +MUri, ex); $Mcurrentstate =State_error; theMtargetstate =State_error; theMerrorlistener.onerror (Mmediaplayer, Mediaplayer.media_error_unknown, 0); the             return; the}finally { - mpendingsubtitletracks.clear (); in         } the}

From 31 lines, you can know that execution Setvideopath () will re-execute Videoview listener events, will re-prepared and so on ...

Android Development video playback call Setvideopath () method

Related Article

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.