Creating the player
Use the following procedure to create a new Apple iOS project to build the basic player for app development.
Extract the opy-sdk-ios-prm-2.30.x-integration.zip to an appropriate location (for example, the project root).
Find the macholib.zip file (in the kop-htc folder) and unzip it.
Open a Terminal window, cd to the unpacked macholib file and run the following command:CODEsudo /usr/bin/python -B setup.py install
- In Xcode create a new Single View project for your application and select the project and the target. On the General tab, add the following frameworks to Linked Frameworks and Libraries:
- AVFoundation
- CFNetwork
- CoreGraphics
- CoreMedia
- Foundation
- libsqlite
- MediaPlayer
- MobileCoreServices
- nmpsdk (from the SDK package)
- Security
- SystemConfiguration
- UIKit
- In the Project Navigator, select the info.plist file and add the following settings (these are the raw key names):
- NSAllowArbitraryLoads YES
- NSAllowsArbitraryLoadsForMedia (boolean) YES
- NSAllowsLocalNetworking (boolean) YES
- NSExceptionDomains (dictionary), with the following child:<domain> (dictionary). This is the domain for which insecure connections are allowed. Add the following children:
- NSExceptionAllowsInsecureHTTPLoads (boolean) YES
- NSIncludesSubdomains (boolean) YES
The relevant section of the plist should now look like this.
In source code view, the relevant section of the file should look like this (with your domain instead of nagra.com).
CODE<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSAllowsArbitraryLoadsForMedia</key> <true/> <key>NSAllowsLocalNetworking</key> <true/> <key>NSExceptionDomains</key> <dict> <key>nagra.com</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> </dict> </dict>
Add a precompiled header file (.pch) as follows
Select File > New > File...
Select iOS and then, under Other, select PCH File and click Next.
In Save As, type Sample_Prefix.
In Targets, select the checkbox for the required target and click Create.
In the Project Navigator, select the .pch file and replace its contents with the following code.CODE#import <Availability.h> #ifndef __IPHONE_7_0 #warning "This project uses features only available in iOS SDK 7.0 and later." #endif #ifdef __OBJC__ #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #import <MediaPlayer/MediaPlayer.h> #endif #define HEADER_WITH_PREFIX(prefix,file) __PREFIXHEADER(prefix,file) #define __PREFIXHEADER(prefix,file) __PREFIX_USE_STR(prefix##_##file) #define __PREFIX_USE_STR(P) #P #if defined(TRACE) || defined(DEBUG) #define NMPCLog(format, ...) NSLog((@"%s " format), __FUNCTION__, ##__VA_ARGS__); #else #define NMPCLog(format, ...) #endif
Select the project and the target and set the following build settings.
Setting Value Architectures > Build Active Architecture Only No (for both Debug and Release) Build Options > Enable Bitcode No Deployment > Strip Debug Symbols During Copy No (for both Debug and Release – the KOP-HTC Patcher needs the symbols to do its job correctly) Deployment > iOS Deployment Target iOS 8.4 or higher Linking > Write Link Map File Yes Search Paths > Framework Search Paths $(inherited) $(PROJECT_DIR)/nmp-sdk/framework
Search Paths > User Header Search Paths $(inherited) $(PROJECT_DIR)/nmp-sdk/cpak
Apple LLVM 8.0 - Language > Prefix Header $(PROJECT_DIR)/Sample_Prefix.pch
If the file location is different from this, change the path accordinglyApple LLVM 8.0 - Language - C++ > C++ language dialect C++11 [-std=c++11]
Apple LLVM 8.0 - Language - C++ > C++ standard library libc++ (LLVM C++ standard library with C++ 11 support) Apple LLVM 8.0 - Language - Modules > Enable Modules (C and Objective-C) No - Rename
viewController.m
toviewController.mm
. InviewController.mm
:Add the following line before the existing
#import
:CODE#import <nmpsdk/NMPSdkHeaders.h>
Add lines after the @interface line so that it looks like this:
CODE@interface ViewController () { NMPAVPlayer *player; }
Replace the existing viewDidLoad method with the following:
CODE#import <Availability.h> #ifndef __IPHONE_7_0 #warning "This project uses features only available in iOS SDK 7.0 and later." #endif #ifdef __OBJC__ #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #import <MediaPlayer/MediaPlayer.h> #endif #define HEADER_WITH_PREFIX(prefix,file) __PREFIXHEADER(prefix,file) #define __PREFIXHEADER(prefix,file) __PREFIX_USE_STR(prefix##_##file) #define __PREFIX_USE_STR(P) #P #if defined(TRACE) || defined(DEBUG) #define NMPCLog(format, ...) NSLog((@"%s " format), __FUNCTION__, ##__VA_ARGS__); #else #define NMPCLog(format, ...) #endif
- In Build Phases:
Click + and select New Run Script Phase.
Expand the new phase. In Shell, type /bin/bash, copy the script below and paste it in Command.The scripts for production and integration builds should be slightly different – the script below is for integration. See Creating a production build for the equivalent script for production.
BASHset -e set -x PATCHER_DIR=/nmp-sdk/kop_htc/patcher echo "PATCHER_DIR = " app_binary=/ echo "app binary = " MD5SUM_FILE_PATH=.md5 echo "MD5SUM_FILE_PATH = " PATCH_REQUIRED=true # calculate binary checksum NEW_CHECKSUM=`stat -f %m ` echo "new checksum = " # compare against checksum in file if [ -f ]; then OLD_CHECKSUM=`cat ` if [ "" = "" ]; then PATCH_REQUIRED=false echo "No patching required" fi fi # Force using native python export PATH="/usr/bin:" echo "using `which python`" if [ = true ]; then dylib_PATH=/libcx_checksum.dylib LIPO_CMD="lipo -create -o " for COP_ARCH in ; do lipo -thin -o ..temp LIPO_CMD=" ..temp " python /patch.pyc --patch-oddd --no-full-checksum ..temp done for COP_ARCH in ; do rm -f ..temp done NEW_CHECKSUM=`stat -f %m ` echo > fi
In Input File, click + and then type .
Drag the Run Script phase up and drop it right after the Link Binary With Libraries phase.
Optionally, rename this phase KOP-HTC Patching Script for easier identification.
Next step: Run the app in clear playback mode.