Design and Implementation of Streaming Media Player Based on Symbian Platform

1 Introduction

This article refers to the address: http://

Following voice calls, SMS services, and data communications, music wireless downloads and real-time playback are becoming one of the emerging services offered by mobile phone operators around the world, causing widespread concern. Compared with the traditional PC-based music player, the advantage of the mobile music player is that it is convenient and fast to download and play, which can bring users a relaxed and comfortable experience. With mobile music players as the medium, operators can rely on their own strong control over mobile communication network services to provide better services to customers. Due to the flexibility and diversity of mobile communication services, it also has a strong scalability in value-added services.

The MulTImedia Framework (MFF) API for the Symbian S60 platform provides multimedia services for upper-level applications, creating and distributing rich music applications for users. As a plug-in set of multimedia processing units, MMF provides a common interface for operating terminal hardware, supports different audio operations, and can implement both local playback and streaming playback modes, and can play multiple audio formats.

In the related literature of the existing Symbian OS-based multimedia player, the design principle of the streaming client of the streaming media player based on the Symbian platform is discussed, and the guiding opinions are given. The optimization suggestions are given in the aspects of structure and buffer. Based on this, the design scheme of the user interface is proposed. However, this document does not give a concrete implementation of multimedia technology. This paper designs and implements a multimedia player based on the Symbian platform, but it only supports local playback, and does not involve related technologies for streaming.

MMusic is a multimedia playback software based on the MMF architecture for playing multiple music files. It not only enables local playback of music files, but also supports streaming. In addition, the music player also supports music download, lyrics download and playback synchronization. Its interface is beautiful, easy to operate and has many functions.

2 system overall frame design

When designing the system framework, firstly define the four basic functions that the player needs to implement: 1 support local audio playback in mp3, wmv, aac and other formats; 2 support streaming audio playback; 3 support song search and download function ; 4 support lyrics synchronization function.

The program of the MMusic player implements an application architecture based on the Symbian S60 platform, using a multi-view framework to construct different views according to different functions. The view includes a play interface (main interface), a search song interface, a music media library interface, and a station list interface. The play interface is the core interface of the entire player, and is mainly responsible for playing audio media, including local play and streaming play.

The corresponding menu and playback engine are dynamically selected according to the playback mode. Local playback uses the CPlayerAdapter engine. The engine uses the audio playback class CMdaAudioPlayerUtility class and its associated observer MMdaAudioPlayerCallback for local audio playback. Streaming is done using the CPluginAdaper engine, which uses the CMdaAudioOutputSTream and MMdaAudioOutputStreamCallback classes.

The MMusic music player is divided into six modules by function:

1UI module, responsible for switching between each interface display and interface, and processing user buttons; 2 local playback module, can provide local audio file playback and volume control services; 3 streaming module to achieve interaction and flow with the server Play; 4 data download module, responsible for audio data download and storage; 5 lyrics synchronization module to ensure synchronization of audio playback and lyrics playback; 6 server module, providing music files and lyrics and other download resources. The relationship between the different modules is shown in Figure 1.

MMusic player function diagram

Figure 1 MMusic player function diagram

3 Introduction of key technologies

3. 1 audio playback

The audio playback function can be implemented through the interface provided by MMF. The audio playback class CMdaAudioPlayerUtility class provides an API for local playback, while the CMdaAudioOutputStream class provides an API for streaming.

3. 1. 1 local playback engine

The MMusic player encapsulates the initialization, playback, pause, etc. of the audio file in the local playback engine CPlayer - Adapter. The engine includes CMdaAudio - PlayerUtility, an audio playback class that supports audio playback operations and simple unit data read operations. Since all its operations are asynchronous, a client is required to *audio playback operations. The playback engine CPlayerAdapter must inherit the MMdaAudioPlayerCallback interface class. The interface class provides two methods, MapcInitComplete() and MapcPlayComplete(). The local playback process is shown in Figure 2. First construct and create an instance of the audio player by calling the CMdaAudioPlayerUtility: : NewFilePlayerL( ) function. When the work of opening and initializing an audio sample ends, the system automatically calls the MapcInit-Complete( ) method to notify the client to create the result of the instance. If created successfully, the CMdaAudioPlayerUtility: : Play( ) method can be called to play the audio file. After a certain audio sampling operation is completed, the system then notifies the client that the playback has been completed through the MapcPlayComplete( ) callback function.

3. 1. 2 streaming engine

For streaming audio playback, the CMdaAudioOutputStreamAPI of the multimedia framework is used. CPluginAdaper is an encapsulated streaming engine that calls the relevant interface for streaming media playback. The main difference between local content playback and streaming playback is the file opening method, initialization method, and processing of the audio data stream.

To implement streaming, you need to write a client class that implements MMdaAudioOutputStreamCallback in your program.

This class provides three callback functions that prompt the client for the streaming process results of the audio output, allowing the program to handle possible errors. These callback functions are MaoscOpenComplete( ) , MaoscBufferCopied() , and MaoscPlay - Complete ( ) , both of which must be implemented by the class of the CMdaAudioOutputStream class. Therefore, CPluginAdaper must inherit the observation class MMdaAudioOutputStreamCallback to get the result of the streaming process.

Local playback flow chart

Figure 2 local playback flow chart

Before implementing streaming, you need to connect to the server to get the audio data stream to be played. In the MMusic player, sockets are used to communicate between the server and the client. The client first needs to connect to the Symbian OS socket server, then open a socket and specify TCP as the transport protocol. The server's IP address and port are then obtained from the list file, and a request is sent to the server. After the server responds, it reads the response data and analyzes it to initialize the playback engine. The client continues to request audio data for playback by the server.

After getting the audio data stream to be played, streaming starts.

The playback process is shown in Figure 3. Initialize the CMdaAudioOutputStream class first. After the initialization is complete, the Multimedia framework calls the MaoscOpenComplete( ) callback function to indicate that the audio output is already available. The argument given by the framework is an error value indicating whether the initialization was successful. If successful, give KErrNONe. Here you can set the sampling rate and volume. After successful initialization, you can call the PlayL( ) function on the client to play the audio stream. It calls the FillBufferL( ) function to fill the data into the buffer and play it using CMdaAudioOutputStream: : WriteL( const TdesC8&aData). The parameter aData is the buffer data.

WriteL( ) is an asynchronous function. After copying the data in the descriptor aData to the audio hardware, the framework will call the MMdaAudioOutputStreamCallback: : MaoscBufferCopied( ) callback method to notify the client that the application has received aData and copied it to the playback stream. At this point, you can continue to fill the buffer by calling the FillBufferL( ) function to achieve continuous streaming.

Streaming flow chart

Figure 3 Streaming flow chart

3. 2 audio file download and resume transmission

MMusic uses Hypertext Transfer Protocol HTTP to download audio files and lyrics. HTTP is an application layer protocol implemented on the TCP / IP protocol for transmitting information over the Internet. It uses Socket to transfer data between the server and the client.

In the Symbian OS release, API support for HTTP clients is provided.

When communicating over HTTP, the client needs to establish an HTTP client session to handle communication with the HTTP server on the session. Establish an HTTP communication transaction on the session. The transaction consists of a request and a response. One or more transactions can be established on the same session. It is also possible to establish multiple sessions at the same time to implement different connections.

When creating the HTTP engine, first create an object of the RHTTPSession class, and then call the Open() method of the class to open the newly created session. Then use the RHTTPTransaction class to represent the HTTP transaction. The transaction is opened in an HTTP client session. When you open a transaction, you need to specify the data transfer method used by the transaction, GET or POST, and pass in the URL to be opened. After the server processing is completed, the response data is returned. The HTTP client processes the response and receives the response data by returning to MHTTP - TransactionCallback.

The download of the song is implemented in two steps. First, the name of the song to be searched is sent to the server using the HTTP engine, and the server returns the file in XML format to the client. The XML file contains information such as the song name, download address, audio file format and size of the searched song. The client parses the file with the XML parser that comes with Symbian, and stores the parsed song information in an array.

The elements of each array are custom structures, including song names, download addresses, and so on.

After the analysis is complete, switch to the list interface. The list interface displays the parsing results of the XML file just downloaded. Users can choose which songs to download based on their preferences. At this point, the client extracts the address of the song download and sends a download request to the server using the encapsulated HTTP engine. The client first determines whether the file to be downloaded already exists. If it does not exist, the audio file is downloaded using the HTTP engine normal download mode. If the file to be downloaded already exists, the existing file size is obtained, and it is passed as an parameter to the HTTP engine, and sent to the server for resumable transmission. The specific code is as follows:



3. 3 lyrics synchronization

First, the user terminal locally searches for a lyric file having the same name as the music file being played. If a file that meets the criteria is found, it is parsed. Each line of the file is stored as an array unit in an array. The unit of the data includes the play time and the lyrics content. The GetPosition( ) function of the CMdaAudioPlayerUtility class obtains the playback position of the current audio file, and compares it with the time of the lyric file recorded in the array to synchronize the lyrics. If the lyrics file is not found, it is downloaded and parsed from the server using the lyrics download engine.

4 software implementation and results

According to the overall architecture design of the player, the music media player is implemented on the Symbian platform and tested in the actual mobile communication network. The test environment is China Mobile's GPRS / EDGE network. The test phone is Nokia N95 and the operating system is V9. 2. The user interface is the third edition of S60. Its ARM clock speed is 11 332MHz and the memory is 160MB. Local audio files play smoothly when tested on a real machine. When playing the content of an online radio station (ie, streaming), its effect will be restricted by the network conditions, but the overall is relatively smooth.

The effect of the player on the real machine is shown in Figure 4. (a) shows the function menu of the player, (b) shows the effect of local playback and lyrics synchronization, (c) shows the status of the connected server during streaming, and (d) shows the streaming of the server after successful connection. Effect, the current connection speed, audio file format, traffic, etc. can be displayed on the interface.

Software rendering

( a) Player function menu ( b) Effect of local playback and lyrics synchronization ( c) Status of connected server during streaming playback ( d) Streaming playback after successful server connection

Figure 4 software renderings

5 Conclusion

The MMusic music player is very good for audio playback, music download, lyrics synchronization and more. On this basis, you can also add some audio effects, so that users have a better audio-visual experience. At the same time, in terms of lyrics synchronization, the program can also add the function of adjusting the lyrics. When the lyrics are not synchronized, the user can adjust according to the actual situation.

In China, as a manufacturer and supplier of Switching Power Supply, we are seeking truth from facts, focusing on product quality and providing the best service to customers.We have experienced engineers to develop products, supervise the quality of products.Our Power Supply 100% full load test before shipment,and with safe packing.We can make the power supply meet every clients needs.

19v Switching Power Supply

19V Switching Power Supply,19V Dc Power Supply,Power Supply 19V,19V Power Supply

Shenzhen Pengchu Industry Co., Ltd , http://www.pc-adapters.com

Posted on