Screen orientation not working with youtubePlayerfragment

后端 未结 1 1173
情书的邮戳
情书的邮戳 2020-12-22 05:39

Currently working on android application which uses youtube api to show video. In this application I\'m showing video in fragment using youtubeplayerfragment. When I click o

相关标签:
1条回答
  • 2020-12-22 06:07

    for saving video state use android:configChanges="keyboardHidden|orientation|screenSize" in your activity tag where your fragment is appearing eg:

    <activity android:name=".activities.MainActivity"
       android:configChanges="keyboardHidden|orientation|screenSize">
    

    in your onFullscreen method check if player fullscreen set or not

    @Override
           public void onFullscreen(boolean b) {
               Log.e("onFullscreen",""+b);
               if(b)
                   fullscreen=1;
               else fullscreen=2;
           } 
    

    in your backpress bethod check if full screen is set then set to false

     @Override
               public void onBackPressed() {
                   if(fullscreen==1)
                   {
                       if(this.player!=null)
                           youTubePlayer.setFullscreen(false);
                   }
                   else
                       super.onBackPressed();
               } 
    

    i hope it helps you, sorry for my bad english

    0 讨论(0)
提交回复
热议问题