Custom UI on exoplayer sample

后端 未结 3 1228
误落风尘
误落风尘 2020-12-08 21:47

** I really need help if you don\'t know anything don\'t give me a negative point :| if something bother you comment**

I want to write custom UI for my player in Exo

3条回答
  •  眼角桃花
    2020-12-08 22:25

    Customizing the ExoPlayer's UI is pretty simple. If you look at the ExoPlayer source, the layout res directory contains the file exo_player_control_view.xml that points to (includes) another layout - exo_playback_control_view.

    1. Copy the contents of the layout resource - exo_playback_control_view.xml
    2. Create a Layout Resource file with any name of your choice - eg: custom_exo_playback_control_view.xml. Paste the copied contents to the new xml
    3. Make whatever changes to the UI widgets as required. Don't change the Id attribute of any widget/control.
    4. Point the custom exoPlayer UI resource in your layout file that contains the PlayerView.

    Here is the custom_exo_controller_view xml that I created from the original. I wanted a different background color for the player controls and different button and progress view colors:

    
    
      
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
      
    
      
    
        
    
        
    
        
    
      
    
    
    

    Below is the code that I use for the player. Notice, the xml attribute app:controller_layout_id points to the custom controller view thats defined above.

    
    
      
    
    
    

    That should get the UI the way you want.

    You can add extra controls as you need in the custom controller and in your code, find the control with findViewById() and write event listeners, etc.

提交回复
热议问题