iPhone Cool Projects phần 8

lớp tiếp nhận các gói dữ liệu âm thanh từ AudioFileStream của chúng tôi, chuyển đổi chúng vào bộ đệm, và sau đó gửi các bộ đệm cho các phần cứng âm thanh. AudioPlayer: Điều này có thể được coi là lớp chỉ huy có trách nhiệm | CHAPTER 6 Serious Streaming Audio the Pandora Radio Way 141 AudioRequest This class is responsible for initiating an NSURLConnection to download our audio and deliver raw bytes to our AudioFileStream. AudioFileStream This is a simple Objective-C wrapper around the plain C AudioFileStream class that receives raw data from the network and parses it into audio packets. AudioQueue This is a simple Objective-C wrapper around the plain C AudioQueue class that receives audio packets from our AudioFileStream converts them into buffers and then sends the buffers to the audio hardware. AudioPlayer This could be considered the commander class that is responsible for controlling audio playback and reporting playback status. AudioPlayer coordinates the transfer of raw audio data from AudioFileRequest into AudioFileStream packets then into AudioQueue buffers and finally onto the audio hardware. How this process works will become clear as we look at the code. In the meantime Figure 6-4 provides a bird s eye view of how audio data flows through the various classes. Implementing the Player Now that you understand the components of our application let s jump right into its implementation. As we proceed into implementation of our application be mindful of earlier tips. For one we re going to avoid using threads as mentioned earlier at the time of this writing the Pandora Radio application uses only one thread for application code . Second we ll make sure to fastidiously handle any errors from the Core Audio API. 142 CHAPTER 6 Serious Streaming Audio the Pandora Radio Way Also we want to make sure our application plays nicely with the iPhone generally. This is no small feat and for audio applications the first place to start is by using AudioSession. AudioSession AudioSession manages the audio profile of our application and helps us cleanly handle interruptions such as incoming phone calls or text messages. If you open and look at the .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.