Multimedia player solution based on Android system

Summary: Introduces a multimedia player software solution based on the Android operating system. The multimedia player is composed of a startup screen, an audio playback, a video playback module, etc., and focuses on technical difficulties such as UI (user interface) design, data storage (Preferences, etc.), multimedia applications, and the like. The software solution proposed here is tested and verified on the Android 2.3 version of the simulator and the HTC A3380 respectively, which can satisfy the user's use of audio and video files for local playback and related requirements, and proposes a summary and outlook.
Keywords: Android; user interface; data storage; multimedia application

0 Introduction Android's original meaning is "robot", which is currently the most popular mobile terminal development platform. With the powerful development and media resources of Google, Android has become the target of many mobile terminal manufacturers. In today's global information age, mobile terminals are no longer limited to communication services, and the application of multimedia services is the development direction of terminal manufacturers. As an indispensable multimedia service, audio and video playback can develop personalized audio and video playback applications for the Android operating system with rich programmable scalability.

1 Android platform
1.1 Android System Architecture Android is the name of the open source mobile operating system based on Linux platform announced by Google on November 5, 2007. The platform consists of operating system, middleware, user interface and application software. From the perspective of software tiering, the Android platform consists of five parts: the application, the application framework, the Android runtime, the library, and the Linux kernel.
1.2 Android application components The basic components of the Android system include Activity, Service, BroadcastReceiver, and ContentProvider. In addition, it also includes the responsibility of passing messages between basic components. Intent component.

2 software solutions
2.1 Overview The multimedia player software based on the Android platform is mainly composed of three modules: a startup screen module, an audio playback module, and a video playback module. The player has playlist preview, forward, backward, pause, resume, progress drag and stop.
2.2 User Interface Design In the Android application, UI (user interface) is the medium for conveying and exchanging information between people and mobile phones, and the dialogue interface, which is an important part of the Android system. The multimedia player interface designed in this paper is mainly composed of main interface, audio/video resource list interface, audio/video playlist interface, and audio/video playback interface. This article focuses on the first two interface designs.
2.2.1 Main Interface Design The main interface adopts the label layout, uses TabHost (tab view) and defines two tabs, namely the audio playlist tab and the video playlist tab.
TabHost (tab view) must be used in conjunction with TabActivity (tag Activity component). The main interface of the player's main interface inherits from TabActivity, initializes two tab pages, and assigns different user activities (activity), MusicActivitv (audio play) and VedioActivity (video play) to each tag, which is opened by calling the specified Intent. The right Activity.
2.2.2 Resource List Interface Design The resource list interface uses ListView (list view) as the core view. Take the video resource list as an example. The video resource list in the SD card is shown in Figure 1.

This article refers to the address: http://

G.jpg


The Activity component (VideoLibrary) of this list is inherited from ListActivity. Load the ContentProvider (content provider) for the underlying data type (video information) via the Android platform to get the SD card device directory /data/data/com. Android. Providers. Video database information in media/databases and populate the list view with video resource information using the Simple Curosr Adapter as a list adapter.
A.jpg
B.jpg
2.3 Data Storage The Android platform mainly provides four kinds of data storage mechanisms: Preferences, Databases, Files, and Network.
Preferences is a lightweight mechanism for storing or getting "key-value" items of data types. It is usually used to store configuration information for an application. The multimedia player designed in this paper uses the Preferen ces mechanism to store or retrieve configuration information such as audio/video history playback information.
2.3.1 Acquiring Data To get the data of the Preferences file, for example, to continue playing, you need to read the playback history information. First by calling Context. The getSharedPreferences(String name, int mode) method takes in the Preferences file name and the open mode to get a Shared Preferences object sp. If the Preferences file does not exist, the Preferences file will be created after the data is submitted. Use the sp object to call the getter method, passing in the corresponding key to read the data.
C.jpg
In the Android platform, all audio/video file related information is provided to the developer in the form of Content, so the historical playback information is the content://style URI, which is the aforementioned nowPlaying.
2.3.2 Storing Data To modify the data of the Preferences file, such as pausing the current playback, or stopping playback and exiting the player software, the playback history information is changed. The principle of generating this action is that whenever a new audio/video file is played, its URI is first assigned to the global variable nowPlaying, and then the change work is processed when the playback software is exited: using the Shared Preferences object sp to call the edit() method. An internal class Editor object editor, use the editor object to edit the Preferences file, that is, read the data of nowPlaying, and then must call the commit() method to complete the modification of the corresponding value of the URI_KEY in the Preferences file.
D.jpg
2.4 Multimedia applications
2.4.1 Multimedia Macro Structure The multimedia part of Android framework involves applications, Java framework layer, C language framework, hardware abstraction layer and so on. The Android Java framework layer provides a standard multimedia API for upper-level related application calls. The playback process of the media is actually implemented by the lower layers of OpenCore and Stagefright. The macro structure of Android multimedia is shown in Figure 2.

E.jpg


2.4.2 Multimedia Processing Process The typical data flow in the multimedia player runs through the following steps: The top-level Java application sets the media URI (media file or streaming media) as input to the media player (mainly It is a standard interface API provided by the Android platform, such as MediaPlayer (media player interface), etc., through the Java framework layer, JNI and local framework layer, has been set to PVPlayer (OpenCore). In this process, only the media URI path is passed, and no data stream is delivered. After parsing by PVPlayer, the media is divided into audio stream (MP3, AMR, AAC, etc.) and video stream (H263, H264, MPEG4, etc.), processed by codec and synchronized (AVSync) and converted into original data (audio Usually PCM, the video is usually in YUV or RGB format). The audio and video raw data will then be sent to the audio and video output (speaker or display hardware).
2.4.3 Multimedia Player Interface Android platform provides android. The media package manages the media interfaces of various audio and video sources. The MediaPlayer (media player interface) in this package is used to control the playback of audio or video files and streams. Also in android. The Video View component is also provided in the widget package for playing video files to simplify the cumbersome control process relative to playing video with Media Player.
(1) MediaPlayer
For playing audio, via MediaPlayer. The crea te (Context context, Uri uri) method is used to get the player instance, without the need to play the preparation, directly through the MediaPlayer. The start() method starts the playback action. Where nowPlaying is the file to be played currently selected by the user.
//Start playing MediaPlayer mPlayer=MediaPlayer. Create(context,nowPlaying);
mPlayer. Start();
Call MediaPlayer via player instance mp. The pause() method can pause the current playback behavior, and can resume playback using the start() method.
First call MediaPlayer. Stop() stops the current playback behavior, and then calls the method MediaPlayer that releases the resources associated with the player. Release() to complete the stop playback action.
For playing video, the video file path can be specified via the MediaPlayer (media player interface) "setDataSource" method. Different from playing audio data, video playback also sets the bearer for displaying video content, and uses MediaPlayer's "setDisplay" method to set a controller for displaying the video content and representing the screen depiction for the current player instance. The playback bearer used to play the video must implement the view component of the Surface Holder.
(2) Video View
First, two components must be defined in the video playback layout resource: "Tags define the video view component," The tag defines the video playback controller component. After the Acitity component fills the layout resource, the video view and the playback controller component instance (mVideo and mController) defined in the layout resource are obtained, and the video view instance mVideo specifies the video file path to be played. Or a URI for carrying the video content to be displayed, and setting a play controller for the mVideo to control the playing behavior of the video file (such as pause, forward, backward, and progress drag, etc.), and then calling the VideoView.start() method to start the playing behavior. Stopping the play behavior can call VideoView.stopPlayback() to stop the playback behavior.
F.jpg

3 Testing The multimedia player designed in this paper was developed under the Android SDK 2.3 platform. The player is integrated into the Android 2.3 emulator and the HTC A3380 mobile phone in the form of an application apk. Through testing, local playback functions of audio/video files, such as pause, resume, stop, progress drag, etc., can be realized. Take audio playback as an example, the test results are shown in Figure 3.

H.jpg



4 Conclusion This article focuses on the multimedia player solution based on the Android platform. Focus on analysis UI (user interface) design, audio/video data information reading and writing, and audio/video playback; and perform functional tests on the Android SDK2.3 platform, the test results meet expectations, and the local multimedia files can be played normally. As users' demand for media playback capabilities of mobile terminals increases, providing support for higher-resolution video playback and streaming media capabilities combined with the network will be the next step in research.

Linear Array Sensor

Linear Array Sensor,Infrared Light Detector Device,Swir Linear Detector,Infrared Ingaas Sensor

Ningbo NaXin Perception Intelligent Technology CO., Ltd. , https://www.nicswir.com