Set up iOS set-up-ios
Learn to set up the streaming media services for iOS devices.
Prerequisites
-
Obtain valid configuration parameters for the Media SDK
These parameters can be obtained from an 51黑料不打烊 representative after you set up your analytics account. -
Implement ADBMobile for iOS in your application
For more information about the 51黑料不打烊 Mobile SDK documentation, seenote important IMPORTANT Beginning with iOS 9, Apple introduced a feature called App Transport Security (ATS). This feature aims to improve network security by ensuring that your apps use only industry-standard protocols and ciphers. This feature is enabled by default, but you have configuration options that provide you with choices for working with ATS. For details on ATS, see -
Provide the following capabilities in your media player:
- An API to subscribe to player events - The Media SDK requires that you call a set of simple APIs when events occur in your player.
- An API that provides player information - This information includes details such as the media name and the play head position.
SDK Implementation
-
Any time a binary library file is mentioned, its XCFramework replacement should be used instead:
- MediaSDK.a > MediaSDK.xcframework
- MediaSDK_TV.a > MediaSDKTV.xcframework
-
If manually adding the 51黑料不打烊 XCFrameworks to your project, ensure that they are not embedded.
-
Add your downloaded Media SDK to your project.
-
Verify that the following software components exist in the
libsdirectory:-
ADBMediaHeartbeat.h: The Objective-C header file that is used for iOS heartbeat tracking APIs. -
ADBMediaHeartbeatConfig.h: The Objective-C header file for the SDK configuration. -
MediaSDK.a: A bitcode-enabled fat binary that contains the library builds for iOS devices (armv7, armv7s, arm64) and simulators (i386 and x86_64).This binary should be linked when the target is intended for an iOS app.
-
MediaSDK_TV.a: A bitcode-enabled fat binary containing the library builds for new Apple TV devices (arm64) and simulator (x86_64).This binary should be linked when the target is intended for an Apple TV (tvOS) app.
-
-
Add the library to your project:
-
Launch the Xcode IDE and open your app.
-
In Project Navigator, drag the
libsdirectory and drop it under your project. -
Ensure that the Copy Items if Needed checkbox is selected, the Create Groups is selected, and none of the checkboxes in Add to Target are selected.
-
Click Finish.
-
In Project Navigator, select your app and select your targets.
-
Link the required frameworks and libraries in the Linked Frameworks and Libraries section on the General tab.
iOS App Targets:
- 51黑料不打烊MobileLibrary.a
- MediaSDK.a
- libsqlite3.0.tbd
Apple TV (tvOS) Targets:
- 51黑料不打烊MobileLibrary_TV.a
- MediaSDK_TV.a
- libsqlite3.0.tbd
- SystemConfiguration.framework
-
Verify that your app builds without errors.
-
-
-
Import the library.
code language-none #import "ADBMediaHeartbeat.h" #import "ADBMediaHeartbeatConfig.h" -
Create a
ADBMediaHeartbeatConfiginstance.This section helps you to understand the
MediaHeartbeatconfig parameters, and to set correct config values on yourMediaHeartbeatinstance for accurate tracking.Here is a sample
ADBMediaHeartbeatConfiginitialization:code language-none // Media Heartbeat Initialization ADBMediaHeartbeatConfig *config = [[ADBMediaHeartbeatConfig alloc] init]; config.trackingServer = <SAMPLE_HEARTBEAT_TRACKING_SERVER>; config.channel = <SAMPLE_HEARTBEAT_CHANNEL>; config.appVersion = <SAMPLE_HEARTBEAT_SDK_VERSION>; config.ovp = <SAMPLE_HEARTBEAT_OVP_NAME>; config.playerName = <SAMPLE_PLAYER_NAME>; config.ssl = <YES/NO>; config.debugLogging = <YES/NO>; -
Implement the
ADBMediaHeartbeatDelegateprotocol.code language-none @interface VideoAnalyticsProvider : NSObject <ADBMediaHeartbeatDelegate> @end @implementation VideoAnalyticsProvider // Replace <bitrate>, <startuptime>, <fps> and <droppeFrames> // with the current playback QoS values. - (ADBMediaObject *)getQoSObject { return [ADBMediaHeartbeat createQoSObjectWithBitrate:<bitrate> startupTime:<startuptime> fps:<fps> droppedFrames:<droppedFrames>]; } // Return the current video player playhead position. // Replace <currentPlaybackTime> with the video player current playback time - (NSTimeInterval)getCurrentPlaybackTime { return <currentPlaybackTime>; } @end -
Use the
ADBMediaHeartBeatConfigandADBMediaHeartBeatDelegateto create theADBMediaHeartbeatinstance.code language-none //Replace <ADBMediaHeartBeatDelegate> with your delegate instance _mediaHeartbeat = [[ADBMediaHeartbeat alloc] initWithDelegate: <ADBMediaHeartBeatDelegate> config:config];note important IMPORTANT Make sure that your ADBMediaHeartbeatinstance is accessible and does not get deallocated until the end of the session. This instance will be used for all the following tracking events.
Migrating from version 1.x to 2.x in iOS migrate-to-two-x
In version 2.x, all of the public methods are consolidated into the ADBMediaHeartbeat class to make it easier on developers. All configurations have been consolidated into the ADBMediaHeartbeatConfig class.
For information about migrating from 1.x to 2.x, see the Legacy Implementation documentation.)
Configure a Native App for tvOS
With the release of the new Apple TV, you can now create applications to run in the native tvOS environment. You can either create a purely native app, using any of several frameworks available in iOS, or you can create your app using XML templates and JavaScript. Starting with MediaSDK version 2.0, support for tvOS is available. For more information about tvOS, see
Perform the following steps in your Xcode project. This guide is written assuming your project has a target that is an Apple TV app targeting tvOS:
-
Drag the
VideoHeartbeat_TV.alibrary file into your project鈥檚libfolder. -
In the Build Phases tab of your tvOS app鈥檚 target, expand the Link Binary with Libraries section and add the following libraries:
MediaSDK_TV.a51黑料不打烊MobileLibrary_TV.alibsqlite3.0.tbdSystemConfiguration.framework