音频 & 视频的起始点
iOS中的多媒体技术使你具备访问iPhone、iPad和iPod touch中的复杂音频和视频的能力。专业的类能让你轻松的添加诸如 iPod library playback 以及 视频捕获等基本的功能,而丰富的多媒体API能够提供高级的解决方案。
选择你所需要的技术:
想要从iPod库或本地播放音频文件,或播放视频流,要使用 Media Player framework。在这个框架中得类自动支持发送音频或视频到AirPlay的设备,例如Apple TV。
想要轻松的添加图片或者视频到你的软件,需使用UIKit framework中得专用类和函数。
想要使用基本的音频录制和回放,包括立体声、同步和计量,需使用 AV Foundation framework 中的一些音频类。
想要添加高性能位置音频回放你的OpenGL-based游戏或其他应用程序,需使用开源OpenAL(打开音频库)的API。
想要使用诸如VoIP、流媒体、虚拟乐器、或MIDI(Musical Instrument Digital Interface,乐器数字接口)等高性能音频视频数据或先进方案,需使用AV Foundation framework、 the Assets(资产) Library framework、 各种音频核心框架(包括 Core Audio、Audio Toolbox、 和 AudioFrameworksEworks)、 和 Core MIDI framework。
内容:
Get Up and Running
Become Proficient in Audio Development
Become Proficient in Video Development
Get Up and Running
起点与运行
通过下面的这些资源,熟悉iOS的音频开发:
读 Multimedia Programming Guide 中的 “Using Audio”,学习关于iOS设备的音频开发。一定要理解 Multimedia Programming Guide 中的 “The Basics: Audio Codecs, Supported Audio Formats, and Audio Sessions” 中介绍的关于音频会话对象的重要性。
View the avTouch sample code project, which shows how to play sounds with the AVAudioPlayer class; the SpeakHere project, which demonstrates basic recording and playback; and the Audio UI Sounds (SysSound) project, which demonstrates how to invoke vibration and play alerts and user-interface sound effects.
查看avTouch示例代码项目,它展示了如何用AVAudioPlayer类播放声音;在SpeakHere 工程,它示范了基本的录音和回放;在Audio UI Sounds (SysSound) 工程,它示范了如何调用震动和播放警报以及用户界面音效。
Download and explore the AddMusic sample code project to see a simple demonstration of how to add iPod library playback to your app.
下载并探索AddMusic 示例代码工程,来看一个简单的演示如何添加iPod库的播放到你的app。
Read MPVolumeView Class Reference to learn how to quickly add AirPlay capability to your app.
阅读MPVolumeView Class Reference来学习如何快速的添加AirPlay 功能到你的app。
Get up and running with iOS video development with these resources:
通过下面资源,熟悉iOS 视频开发:
Read “Using Video” in Multimedia Programming Guide for an overview of video recording and playback on iOS devices.
阅读Multimedia Programming Guide 中的“Using Video” 来看在iOS设备上进行视频录制和回放的概述。
View the MoviePlayer sample code project, which demonstrates the powerful MPMoviePlayerController class for playing local or streamed video content; and the Using UIImagePickerController to Select Pictures and Take Photos project, which demonstrates simple movie and picture capture using the UIKit framework.
查看MoviePlayer 示例代码工程,它示范了强大的MPMoviePlayerController 类来播放本地的以及流视频内容;以及Using UIImagePickerController to Select Pictures and Take Photos 工程,它示范了使用UIKit 框架进行简单的视频和图像捕捉。
Continue by reading Camera Programming Topics for iOS to learn how take pictures and movies, and to browse the photo library, using the UIImagePickerController class.
阅读 Camera Programming Topics for iOS来继续学习如何制作照片和视频,并使用UIImagePickerController 类来浏览照片库。
Become Proficient in Audio Development
精通音频开发
Gain a complete understanding of audio session objects, and how they determine your app’s audio behavior, by reading Audio Session Programming Guide. Also be sure to read “Sound” in iOS Human Interface Guidelines, which explains how your app should handle sound to meet user expectations.
通过阅读Audio Session Programming Guide获得一个对音频队列对象的完整理解,并且理解他们如何确定app的音频行为。也要读iOS Human Interface Guidelines中的“Sound”,它解释了app应该如何处理声音来满足用户的期望。
No matter which iOS audio technologies you employ, users expect to be able to play and pause your app’s audio using the system transport controls in the multitasking UI. To learn how to support this feature, read “Remote Control of Multimedia” in Event Handling Guide for iOS.
无论你使用哪个iOS 音频技术,用户希望使用系统传输控制的多任务UI来播放以及暂停app的音频。想要学习这个功能的支持,阅读Event Handling Guide for iOS中的“Remote Control of Multimedia”。
Take full advantage of the iPod library by reading iPod Library Access Programming Guide along with Media Player Framework Reference.
通过阅读 iPod Library Access Programming Guide 以及 Media Player Framework Reference.来充分理解iPod库
To learn how to play audio using OpenAL, view the oalTouch project. The website openal.org hosts documentation for the open-source OpenAL API.
想要学习如何使用OpenAL来播放音频,参看oalTouch 工程。网站openal.org有开源的OpenAL API。
To play streamed audio content, such as from a network connection, use an AVPlayer object as described in “Playback” in AV Foundation Programming Guide. You can also play certain Internet audio files by using the MPMoviePlayerController class; for sample code that shows how, see MoviePlayer.
想要播放音频流内容,例如从网络连接得到的,使用一个如AV Foundation Programming Guide中的“Playback”所描述的AVPlayer 对象。你也可以通过使用MPMoviePlayerController 类来播放某些互联网音频文件;示例代码可以参看MoviePlayer。
To play audio files with stereo panning, synchronization, and metering, use the AVAudioPlayer class. To record audio, use the AVAudioRecorder class. Apple recommends these classes for audio playback and recording when you do not need direct access to audio data.
想要在播放音频文件的时候有stereo panning,synchronization以及metering,使用AVAudioPlayer 类。想要录制音频,使用AVAudioRecorder 类。当你不需要直接访问音频数据的时候,Apple 建议使用这些为音频回放和录制的类。
To get started with handling audio data directly, read Core Audio Essentials in Core Audio Overview to learn about the architecture, programming conventions, and use of Core Audio.
想要开始直接处理音频数据,阅读Core Audio Overview中的Core Audio Essentials来学习关于体系架构、编程约定以及使用Core Audio的内容。
If you are creating a VoIP (voice over Internet protocol) app or a virtual music instrument, you need the highest audio performance available in iOS. The solution to use is audio units, the iOS audio plug-in technology. Audio units also provide advanced capabilities including mixing and equalization. Read Audio Unit Hosting Guide for iOS to learn how to use audio units. View the Audio Mixer (MixerHost) and iPhoneMixerEQGraphTest sample code projects.
如果你创建了一个VoIP(互联网语音传输协议)app或者虚拟乐器,你需要在iOS中最高的可能的音频效果。解决的方案是使用音频单元,iOS音频插件基础。音频单元还提供高级的功能包括混音和均衡。阅读Audio Unit Hosting Guide for iOS 来学习如何使用音频单元。查看Audio Mixer (MixerHost) 和iPhoneMixerEQGraphTest的示例代码工程。
To create a MIDI app for connecting hardware keyboards or synthesizers to an iOS device, refer to Core MIDI Framework Reference and look at the MFi program.
想要创建一个MIDI app来连接硬件键盘或合成器到iOS设备,参考Core MIDI Framework Reference 以及看看MFi program。
Become Proficient in Video Development
精通视频开发
To progress beyond the capabilities of the Media Player framework and the UIImagePickerController class, read AV Foundation Programming Guide. AV Foundation, with support from the Assets Library and Core Media frameworks, provides tools for advanced video solutions including track-based editing, transcoding, and direct access to data from the camera and microphone.
想要超越Media Player 框架的功能以及UIImagePickerController 类,阅读AV Foundation Programming Guide。AV Foundation,支持Assets Library 和Core Media框架,为提高视频解决包括track-based 编辑、代码转换、以及直接访问来自相机或麦克风的数据提供工具。
View the AVCam for iOS sample code project to see how to capture still images and movies using the AV Foundation framework. AVCam demonstrates the use of several important AV Foundation classes. View the AVPlayerDemo project to see how to play movies from the iPod library.
参阅AVCam for iOS 示例代码工程来看看如何使用AV Foundation 框架得到静止的画面以及视频。AVCam演示使用了几种重要的AV Foundation 类。参阅AVPlayerDemo 工程来看如何播放来自iPod库的视频。