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