How can I get an Android MediaController to appear from layout xml?

前端 未结 7 1727
无人及你
无人及你 2020-12-28 11:10

I\'ve created a layout.xml file with the following XML, but I can\'t get the MediaController to appear at all.



        
相关标签:
7条回答
  • 2020-12-28 12:13

    By using show(0) media controller will be shown until hide() is called by an interaction with the player. I found unfortunately no way to prevent hide() yet;-(

    MediaController mc = new MediaController(MPlayer.this);  
     mc.setMediaPlayer(MPlayer.this);  
     mc.setEnabled(true);
    
     View mMediaControllerView = (View)findViewById(R.id.media_controller); //get it from your layout
    
     mc.setAnchorView(mMediaControllerView);
     mMediaControllerView.setOnTouchListener(mPlayerTouchListener);//also use show() in onTouchListener
    
     new Handler().postDelayed(new Runnable() {
    
         public void run() {
            mc.show(0);
         } }, 1500);
    

    Wait for screen to buid in order to avoid a bug in android (1,5 seconds here)

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