Objective
With the " Calculator " Application We are already familiar with the general process of Android application development, with the initial knowledge of development.
Next, we'll start making a " video player " app that will further deepen our learning of program development.
When this " video player " app is completed, you will be able to independently develop an Android application that is slightly more complex.
The reader for this article is:
- Have a preliminary understanding of the development of Android, but have no experience of the newcomers;
- Developers who have no systematic collation of existing Android development experience;
Before you start, let's say you're ready to do the following:
- A development with a notebook computer, and set up a good development environment;
- An Android device (mobile or tablet);
- A video file that can be played is stored on the device;
- A data cable (usually a micro USB cable) connecting the computer and the Android device;
- one or both days;
- Patience and curiosity;
The code for this article can be downloaded from the example code of the Bean network.
Section 1th Design Scenario 1.1 possible function points
Although it is a simple video player, but small perfectly formed, may need to prepare the following features:
- Display the video that exists on the device;
- Can display detailed information of a video, such as video file size, video resolution and so on;
- After selecting a video, you can play the video;
- Can control video pause, continue, fast forward, rewind when playing video;
- Can play the video in full screen;
- Can be provided to the system for use as an optional player for playing video files;
- If there is a telephone connection, the player can automatically pause the playback;
- Can manage video files, such as deleting one or more videos;
- Video can be suspended on other applications to play, while brushing, while watching video;
1.2 Trade-offs between functional breadth and functional depth
Each function looks like a sentence, but careful analysis, there are a lot of details to consider.
For example, 功能1
if you show all the video on your device,
- May take a long time;
- Each video should have thumbnails, if the search for these video files, and create thumbnails for them, may be very memory consumption, if the video is very large, it is possible to exhaust the Android system allocated to an application of the largest memory usage, resulting in a program crash;
- When the player finds the video file and displays it, if the user deletes the file that has been displayed to the list through another tool, such as the player is refreshing the list and displaying the file
1.mp4
to the list, the user uses the PC-side phone management software 1.mp4
to This file removed from the device (the process of the player to refresh the video file is not over), then the phone's display list to be able to immediately find this accident, update again;
- May also have a lot of short video files on the device, maybe only dozens of k or hundreds of K, is not the user's concern for video, such as the short video received, the user will not use our video player to play;
- It may also be that users simply do not want the player to find some "sensitive" video files;
This is what we need to solve in the development of real problems. 功能1
we can solve all of these problems with good design. But the price may be,
- Increase the complexity of the program and spend more time on development;
- To solve one problem, introduce another one that is more difficult to solve and introduce another potential bug.
- Development into a dead end, everywhere is to solve the problem, do not know how to start;
You know, this is just 功能1
the problem raised in the question, do not know the other function points will also increase the complexity of an application to what extent.
Therefore, for the project planners and developers of the program, the need for a single full-featured depth and the breadth of the implementation of multiple functions, to make a wise choice.
Fortunately, the release of the software is not affair, it can be upgraded after the release. So we usually start with the most important features, and the most important features are the easiest to implement.
Later on to expand the function, the implementation of the scheme to modify, gradually become more and more perfect. This process is also more suitable for beginners to master the idea of program design, accumulate the experience of development, know the same function, how to design more suitable, why this design.
So, for our first version of the video player, we will try to use the simplest design, not too much consideration of its program structure and performance, the focus is to use a simple and correct way to make the function, and later in the new version of iterative optimization.
1.3 Functions of the present stage
To simplify the problem, let's make this assumption about the environment and functionality that the video player allows:
- Read only the video files in a specific directory, such as
Video
the directory named;
- Suppose the user is not so BT: in the display of the video list, with other tools, the file has been displayed to delete;
- When enumerating video files, it is possible to pause because of the length of time.
- The number of video files is not particularly outrageous, tens of thousands of videos will not be encountered;
- Only play the system natively supported video formats;
- When the player in the horizontal screen, automatically switch to full screen, in the vertical screen, occupy some areas, the rest of the area display video details;
- No video playback record, the user actively quit the case, the next time the same video will be played from the beginning;
- No video management function, can not change the location of video files, can not delete it, can not modify the file name;
- No hover play function;
As a result, the interface of the video player is designed as follows:
1.4 About regrets
For those not added at this stage of the function, look forward to join it;
For those simple design to simplify the development difficulty and reduce the development time, look forward to the next version of the program to optimize and perfect it;
Of course, don't forget that the goal of this app is to teach you more about Android development skills. Therefore, in choosing the implementation of the scheme, focus on the principle of the display, not necessarily the implementation of the best efficiency of the scheme.
Teach you to do video player (i)