Displaying Web and Multimedia Content
OS X and iOS provide an assortment of APIs to allow you to display web content and streaming multimedia content. In general, if these higher-level multimedia- and web-specific APIs meet your needs, you should use them rather than using networking APIs directly. The sections below briefly summarize these APIs.
Opening Web Content or Streaming Media in the Default Application
To open a webpage or streaming URL in the user’s default browser or media viewer:
In iOS, use the
openURL:method of theUIApplicationclass.For a real-world example, see QA1629: Launching the App Store from an iOS application.
In OS X, use the
LSOpenCFURLReforLSOpenFromURLSpecfunctions in the Launch Services API.For details, see Launch Services Tasks in Launch Services Programming Guide.
Displaying Web Content in Your Application
OS X and iOS provide an easy way to load and display a webpage with the WebKit engine, the same rendering engine used by Safari.
In OS X, you load web content with the
WebViewclass. You can add a web view by including it in your application’s nib file or by programmatically constructing aWebViewobject and calling theinitWithFrame:frameName:groupName:method. Load content by calling theloadRequest:method on the web view’s main frame (which you can obtain with themainFramemethod).In iOS, you load web content with the
loadRequest:method of theUIWebViewclass. You can add a web view by including it in your application’s nib file or by programmatically creating aUIWebViewobject and initializing it with theinitWithFrame:method.
For more information, see Simple Browsing in WebKit Objective-C Programming Guide (OS X) and UIWebView Class Reference (iOS).
Displaying Streaming Multimedia Content in Your Application
There are several frameworks available for displaying streaming multimedia content in OS X and iOS:
In OS X, use the QTKit Framework for basic playback or the AV Foundation framework for more complex functionality.
In iOS, use the Media Player Framework for basic playback or the AV Foundation framework for more complex functionality.
For more information, read Getting Started with Audio & Video, Multimedia Programming Guide (iOS), QTKit Application Programming Guide (OS X), and AVFoundation Programming Guide.
Copyright © 2004, 2017 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2017-03-27