Android uses vitamio to build its own universal player (3) – local playback (main interface, playlist)
preface
Building a complete and available Android player has many functions and details to complete, and also involves a variety of rich knowledge and content. This chapter will combine fragment and viewpager to build the main interface of the player and realize the basic functions of local playback. Series of articles provide screenshots, code description, source code download, welcome to communicate!
series
1. Android uses vitamio to build its own universal player (1) -- ready
2. Android uses vitamio to build its own universal player (2) - gesture to control brightness, volume and zoom
text
1、 Target
1.1 use fragment and viewpager to build the main interface
The main functions are divided into local video and online video, and sliding switching module is allowed
1.2 display all sdcard videos with listview
Effect screenshot:
(statement: the icons are from the Internet and are only for learning and research!)
2、 Implementation code
2.1 xml
This is the overall layout. Use RadioButton to switch between local video and online video functions. Please download the project for specific styles. Viewpager supports left and right side sliding switching function.
2.2 class
MainFragmentActivity
Here is a simple example of the combination of fragment and viewpager.
FragmentFile
Code Description:
a) Here is the main function of this chapter. Scan all video and audio files and display them.
b) Arrayadapter and FileUtils do not paste codes one by one here, mainly tools and auxiliary classes. Please download the project to view.
c) . note: the madapter.add operation should be placed in the main thread, otherwise an error may occur.
The above is to sort out the data played locally by Android vitamio. Thank you for your follow-up.