Analysis of music apps (for example, QQ music) and appqq
<1> the core function of QQ music is playing songs.
First, you can use the AVFoundation framework to play audio. However, AVFoundation can only play local music and cannot play it online. Although you can download resources from the network to the local computer before playing the video, you must download all the songs before playing the video.
!
If you want to play the video online, you can select Audio Queue Services in the AudioToolbox framework. The audio queue service can complete audio recording and playback.
An Audio Queue consists of three parts:
Three Buffers: Each buffer is a temporary repository for storing audio data.
Buffer Queue: an ordered Queue containing audio buffers.
One Callback: a custom queue Callback function.
Audio playback process:
Read the audio into the buffer. Once a buffer is filled up, it is placed in the buffer queue and continues to fill in other buffers. When playing the video, then, the system reads the audio from the first buffer and plays the video. Once the video is played, the callback function is triggered to play the audio from the next buffer and fill it with the first buffer; after filling up, it is placed back to the buffer queue.
Streaming Media
A good player must ensure smooth playback. It must be played while loading. If it is better, it can be played Using Streaming Media.
Details...
<2> obtain a song order and display it in the industry
This part mainly uses AFN to obtain the song information from the network and then display it on the interface. Familiar with the interface display, which is difficult to do. Supplement
<3> download songs to local storage
It is also important to manage offline song downloads. The song name, author, and other related information can be stored in the database, the song source file and the lyrics file, downloaded and saved to the folder specified in the sandbox.
<4> other settings and other functions are similar to those of other software.
You can refer to the QQ player for a detailed explanation of how it is implemented.