Documents
Integration with AVPlayer (IOS)


This article provides a general description of the steps to follow to integrate Teltoo with AVPlayer, used in iOS devices. 

The integration can be done with both Objective-C and Swift.

Disable App Transport Security for local Networking

This step is required with both Objective-C and Swift. In the Project Navigator, right-click on “Info.plist”, and “Open as” → “Source Code”. Add the following lines:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsLocalNetworking</key>
    <true/>
</dict> 

Integrating with Objective-C

  1. Import TeltooSDK
#import <TeltooSDK/TeltooSDK.h>
  1. Declare TeltooSDK as an instance variable
@property (nonatomic, strong) TeltooSDK *teltooSdk;
  1. Implement the TeltooSDK delegate with the following interface
@protocol TeltooSdkDelegate <NSObject>
-(void) onState:(bool)connected;
-(void) onMessage:(NSString *)message;
-(void) onError:(NSString*)description;
-(void) onStatsConnectedPeers:(uint32_t)connectedPeers
    totalBytesReceived:(uint64_t) totalBytesReceived
    p2pBytesReceived:(uint64_t) p2pBytesReceived
    cacheBytes:(uint64_t) cacheBytes
    requestWithoutTeltoo:(uint32_t) requestWithoutTeltoo;
@end
  1. Initialize the TeltooSDK
_teltooSdk = [[TeltooSDK  alloc] 
initWithApiKey:@"YOUR_TELTOO_API_KEY" andDelegate:self];
  1. Setup AVPlayer
NSURL *streamURL = [NSURL URLWithString:playlistUrl];
NSURL *teltooUrl = [_teltooSdk getTeltooUrl:streamURL];
_player = [AVPlayer playerWithURL: teltooUrl];

Integrating with Swift

  1. Import TeltooSDK
import teltooSDK
  1. Implement the TeltooSDK delegate with the following interface
func onState(_ connected: Bool) {
}
func onMessage(_ message: String) {
}
func onError(_ description: String) {
}
func onStatsConnectedPeers(
    _ 
    connectedPeers: UInt32,             
    totalBytesReceived: UInt64,     
    p2pBytesReceived: UInt64, 
    cacheBytes: UInt64, 
    requestWithoutTeltoo: UInt32) 
{
}
  1. Initialize the TeltooSDK
let _teltooSDK: TeltooSDK = TeltooSDK(apiKey:YOUR_TELTOO_API_KEY, andDelegate:self)
  1. Setup AVPlayer
let teltooUrl = _teltooSDK.getTeltooUrl (videoURL! as URL);
let playerAV = AVPlayer(url: teltooUrl as URL)



Want to know more?

Talk to an expert