Teach you to do video player (i)

Source: Internet
Author: User

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:

    1. Have a preliminary understanding of the development of Android, but have no experience of the newcomers;
    2. 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:

    1. Display the video that exists on the device;
    2. Can display detailed information of a video, such as video file size, video resolution and so on;
    3. After selecting a video, you can play the video;
    4. Can control video pause, continue, fast forward, rewind when playing video;
    5. Can play the video in full screen;
    6. Can be provided to the system for use as an optional player for playing video files;
    7. If there is a telephone connection, the player can automatically pause the playback;
    8. Can manage video files, such as deleting one or more videos;
    9. 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,

    1. May take a long time;
    2. 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;
    3. 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;
    4. 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;
    5. 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. 功能1we can solve all of these problems with good design. But the price may be,

    1. Increase the complexity of the program and spend more time on development;
    2. To solve one problem, introduce another one that is more difficult to solve and introduce another potential bug.
    3. 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:

    1. Read only the video files in a specific directory, such as Video the directory named;
    2. Suppose the user is not so BT: in the display of the video list, with other tools, the file has been displayed to delete;
    3. When enumerating video files, it is possible to pause because of the length of time.
    4. The number of video files is not particularly outrageous, tens of thousands of videos will not be encountered;
    5. Only play the system natively supported video formats;
    6. 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;
    7. No video playback record, the user actively quit the case, the next time the same video will be played from the beginning;
    8. No video management function, can not change the location of video files, can not delete it, can not modify the file name;
    9. 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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.