Android picture, video, music selection player

1. Design purpose

In order to have a deeper understanding of Android development, I originally planned to design a photo album or video-related multimedia application, but by chance I saw a framework in github, which defined many related pictures and videos. The method of operation, and can obtain the local files of the mobile phone, unlike the previous application that needs to be imported into drawable or obtained online, so I decided to use github
https://github.com/LuckSiege/PictureSelector for this course design The open source framework makes an application that can view the data stored in the background of the mobile phone, so that it is convenient to find out the pictures, music and videos stored in various locations in the mobile phone, such as pictures taken by the mobile phone, locally downloaded videos, or locally downloaded music. It is convenient to preview when selecting, similar to mobile phone photo album.

2. Function description

  1. Preview and view the photos, videos and audios stored in the mobile phone, and you can find various types of photos, videos and audios stored in the mobile phone through the application, including png, jpg, jpeg and other formats
  2. Single-select or multi-select the photos, audio and video stored locally on the mobile phone, and return the selected photo, video and audio to the home page for display
  3. Take photos, video or audio recordings, and return the results to the home page for display
  4. Play selected photo, video and audio on home page

3. Detailed design

3.1 System business logic

Business Logic Flowchart

insert image description here

3.2 System function module design

insert image description here

3.3 System interface design

  1. Home: Display the files you have selected.
  2. On the operation options page, click on the home page to enter the operation selection page, where you can choose whether to add photos, videos, audio, or take pictures.
  3. Local file display page: display the local files (pictures, videos, audios) of the mobile phone in a way similar to the mobile phone album, which can be selected and previewed
  4. File preview page: Click the file you want to select, and the file will be previewed

4. Program implementation

First of all, since I used a third-party integration framework, I first need to use gradle to import
allprojects { repositories { jcenter() maven { url 'https://jitpack.io' } } } and then create the xml file in the layout. First, use the homepage RecyclerView is used to facilitate the arrangement of the selected pictures, and use the relative layout and imageview and the layout in the library to display pictures and videos. In MainActivity, use getviewbyid to get the ui control in the layout, new a GridImageAdapter to store the selected file, and then judge the type of the stored file by using the function integrated in the library, and use the switch function to use different methods of integration to open the respective corresponding document.








insert image description here

And if you want to get the local files of the mobile phone, you need to apply for the permission to write
insert image description here

Then design and click the corresponding listener for the ui control, use the getid of the control to judge the response event, and use the function in the library to display the local photo album of the mobile phone and perform related operations in each corresponding event.
insert image description here

5. Running results

insert image description hereinsert image description here

Choose an album:
insert image description hereinsert image description hereinsert image description here

On the left is the interface of my application, and on the right is the interface of the gallery that comes with the simulator. You can see that the application has found all the folders including pictures in the simulator, and also obtained all the pictures and videos saved locally on the phone.
insert image description hereinsert image description hereinsert image description here

You can click on the picture to preview it, or swipe left and right to select a different album.
insert image description hereinsert image description hereinsert image description here

The selected picture will return to the home page for display, and you can also enter the viewing page on the home page

insert image description hereinsert image description hereinsert image description here

When audio is selected, all local audio is displayed and can be played after clicking
insert image description hereinsert image description here

After selecting the video, you can also play it and choose to go to the home page.
insert image description hereinsert image description hereinsert image description here
You can also record video, take pictures, and record audio.

6. Summary

  • In this experiment, I used the open source library in github, which contains a lot of knowledge that I have not learned in the classroom, such as the acquisition of file operation permissions, the import of open source libraries, and the implementation process of different shootings such as video recording, photo taking, and video recording.
    But there are also some learned
  • The knowledge has been deepened, such as how to arrange pictures neatly in layout page design, how to learn to use RecyclerView; when adding monitoring events to controls, use the getid and switch of view to add events to different controls; use adapters to put photos Different files such as video and video, and add their own click response events for each picture, video, etc. in the adapter to complete the viewing of selected files on the home page.
  • There are also many things that can be improved in this system. For example, there are many problems when importing the library and using it. Some problems have been solved, but some have not been solved. For example, there is a function of cropping and rotating pictures in the open source library, but When using it, the application will be closed, and no error message will be displayed in the log. In the end, there is no solution, so we have to give up this function; the name of the file cannot be displayed when making a selection, and the picture can be viewed directly, but the video and audio must be displayed. Open the playback to determine the file name.

source address

https://github.com/1105358600/AndroidPVASelector

Guess you like

Origin blog.csdn.net/qq_45808700/article/details/117907219