EcoCDN P2P WebRTC
  • Introduction
  • HLS INTEGRATION
  • HTML5 Players
  • VideoJS Player
  • Android Integration
    • Environment Configuration
    • Import Android-SDK
    • Quick Start
    • Advanced Usage
    • API & Config
  • IOS INTEGRATION
    • Requirements
    • Project Setup
    • Integration
    • Advanced Usage
Powered by GitBook
On this page

Was this helpful?

  1. IOS INTEGRATION

Integration

Copy the framework

Unzip files, then drag and drop SwarmCloudSDK.xcframework and WebRTC.xcframework into your Xcode project on your application targets’ General settings tab, in the Frameworks, Libraries, and Embedded Content section.

https://ecocdn.net/ios_sdk/SwarmCloudSDK.xcframework.zip
https://ecocdn.net/ios_sdk/WebRTC.xcframework.zip

In order to allow the loading of distributed content via the local proxy, enable loading data from HTTP in your app by opening your info.plist file as source code and adding the following values below the tag:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

Import SwarmCloudSDK in AppDelegate.m:

swift

import SwarmCloudSDK

objective-c

#import <SwarmCloudSDK/SwarmCloudSDK.h>

Initialize SWCP2pEngine

Initialize SWCP2pEngine in AppDelegate.m:

swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    SWCP2pEngine.sharedInstance().start(token: YOUR_TOKEN, p2pConfig: nil)
    return true
}

objective-c

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[SWCP2pEngine sharedInstance] startWithToken:YOUR_TOKEN andP2pConfig:nil];
    return YES;
}

Where YOUR_TOKEN is your Customer ID.

Usage

When initializing an AVPlayer (or any other video player) instance, before passing it a URL, pass that URL through P2P Engine:

swift

let orginalUrl = URL.init(string: "https://your_stream.m3u8")
let parsedUrl = SWCP2pEngine.sharedInstance().parse(streamURL: orginalUrl)
_player = AVPlayer.init(url: parsedUrl)

objective-c

NSURL *originalUrl = [NSURL URLWithString:@"https://your_stream.m3u8"];
NSURL *parsedUrl = [[SWCP2pEngine sharedInstance] parseStreamURL:originalUrl];
_player = [[AVPlayer alloc] initWithURL:parsedUrl];

That’s it! SDK should now be integrated into your app.

PreviousProject SetupNextAdvanced Usage

Last updated 3 years ago

Was this helpful?