--- title: "iOS 환경" slug: "vpe-ios" updated: 2026-09-17T09:22:05Z published: 2026-09-17T09:22:05Z canonical: "guide.ncloud-docs.com/vpe-ios" stale: true --- > ## Documentation Index > Fetch the complete documentation index at: https://guide.ncloud-docs.com/llms.txt > Use this file to discover all available pages before exploring further. # iOS 환경 Classic/VPC環境で利用できます。 iOS環境では、iOS専用プレイヤー開発のための Video Player Enhancement iOS SDKの使用方法とプレイヤー適用およびオプション設定方法について説明します。 参考 iOS用 Video Player Enhancement SDKを使用するためには、Standard料金プランを利用する必要があります。ご利用のためには、次のような仕様が要求されます。 - 最小仕様: iOS 14.0以上 - 開発環境: Xcode ## SDKのインストールと環境設定 SDKをインストールしてフレームワークを追加する方法は、次の通りです。 1. NAVERクラウドプラットフォームコンソールで、 **Menu** > **All Services** > **Media** > **Video Player Enhancement**メニューを順にクリックします。 2. **Video Player Management** メニューをクリックします。 3. プレイヤーリストから SDKをダウンロードするプレイヤーの **[SDKアドレス]** ボタンをクリックします。 4. **モバイルネイティブ SDKsダウンロード** の **[IOS]** ボタンをクリックします。 - 圧縮ファイルがダウンロードされます。 1. Xcodeを実行したら、追加したいプロジェクトの **Targets > General** メニューを順にクリックします。 2. **Framework, Libraries, and Embedded Content** に 「NCPlayerSDK.xcframework」を **Embed & Sign** タイプで追加します。 ## プレイヤーの適用と設定 プレイヤーを適用してオプションを設定するためには、次の手順に従います。 - [1. 初期化](/docs/ja/vpe-ios#1%EC%B4%88%EA%B8%B0%ED%99%94) - [2. プレイヤー設定](/docs/ja/vpe-ios#2%ED%94%8C%EB%A0%88%EC%9D%B4%EC%96%B4%EC%84%A4%EC%A0%95) - [3. イベント設定](/docs/ja/vpe-ios#3%EC%9D%B4%EB%B2%A4%ED%8A%B8%EC%84%A4%EC%A0%95) ### 1. 初期化 次のように NCPlayerSDKインスタンスを初期化し、Delegateを設定します。 ``` import NCPlayerSDK ... class ViewController: UIViewController, NCPlayerDelegate{ ... override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) NCPlayer.shared.delegate = self } } ``` ### 2. プレイヤー設定 プレイヤーを設定する方法は、次の通りです。 1. NAVERクラウドプラットフォームコンソールで、 **Menu** > **All Services** > **Media** > **Video Player Enhancement**メニューを順にクリックします。 2. **Video Player Management** メニューをクリックします。 3. 設定するプレイヤーの **[SDKアドレス]** ボタンをクリックします。 4. Player SDKアドレスのポップアップが表示されたら、 **SDKアドレス** から access_key値を確認します。 ![vpe-ios_key_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/vpe-ios_key_ja.png?sv=2026-02-06&spr=https&st=2026-10-30T22%3A48%3A07Z&se=2026-10-30T23%3A48%3A07Z&sr=c&sp=r&sig=unldYvrFunFGFJihrVY7fctL2zrEVnx7iGb5PAnWGDY%3D) 5. Xcodeで NCPlayerViewを参照する Classと UIViewを作成します。 6. プレイヤーのオプションを設定します。 ``` class player:NCPlayerView{} class ViewController: UIViewController, NCPlayerDelegate { @IBOutlet weak var playerView: player? } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) // SDKを初期化 //licenseKey = access_key let licenseKey = "{access_key}" // プレイヤーオプション(コンソールで作成されたスクリプトコードを使用) let playerOptions = """ { "playlist":[ { "file":"https://CDNドメイン/example_video_01.mp4", "poster":"https://CDNドメイン/example_video_01.png", } ], "autostart":true, } """ NCPlayer.shared.initialize(licenseKey: licenseKey) NCPlayer.shared.delegate = self // 実行 playerView?.play(playerOptions) } ``` - [プレイヤー設定](/docs/ja/vpe-web#%ED%94%8C%EB%A0%88%EC%9D%B4%EC%96%B4%EC%84%A4%EC%A0%95)とこのガイドのプレイヤー設定スクリプトをご参照ください。 ### 3. イベント設定 Player Event APIを通じて Video Player Enhancementプレイヤーで発生するイベントバインドして活用できます。方法は次の通りです。 1. `NCPlayerNetworkStatus` メソッドを利用してデバイスのネットワーク接続状態を確認します。 ``` import NCPlayerSDK ... class ViewController: UIViewController, NCPlayerDelegate{ ... func NCPlayerNetworkStatus(state: String) { // state: satisfied = 異常なし(ONLINE) // state: unsatisfied = 問題発生(OFFLINEまたは通信障害発生) // state: requiresConnection = 現在は利用できないが、インターネットに接続すれば利用可能 } } ``` 2. 設定したいイベントに応じて設定方法を確認します。 - [横向きモード有効化イベント](/docs/ja/vpe-ios#%EA%B0%80%EB%A1%9C%EB%AA%A8%EB%93%9C%ED%99%9C%EC%84%B1%ED%99%94%EC%9D%B4%EB%B2%A4%ED%8A%B8) - [スクリーンキャプチャ検知イベント(iOS専用)](/docs/ja/vpe-ios#%EC%8A%A4%ED%81%AC%EB%A6%B0%EC%BA%A1%EC%B2%98%EA%B0%90%EC%A7%80%EC%9D%B4%EB%B2%A4%ED%8A%B8iOS%EC%A0%84%EC%9A%A9) - [OS画面録画検知イベント(iOS専用)](/docs/ja/vpe-ios#OS%ED%99%94%EB%A9%B4%EB%85%B9%ED%99%94%EA%B0%90%EC%A7%80%EC%9D%B4%EB%B2%A4%ED%8A%B8iOS%EC%A0%84%EC%9A%A9) - [TimeUpdateイベント](/docs/ja/vpe-ios#TimeUpdate%EC%9D%B4%EB%B2%A4%ED%8A%B8) - [PrevTrackイベント](/docs/ja/vpe-ios#PrevTrack%EC%9D%B4%EB%B2%A4%ED%8A%B8) - [NextTrackイベント](/docs/ja/vpe-ios#NextTrack%EC%9D%B4%EB%B2%A4%ED%8A%B8) - [コントロールバー有効化イベント](/docs/ja/vpe-ios#%EC%BB%A8%ED%8A%B8%EB%A1%A4%EB%B0%94%ED%99%9C%EC%84%B1%ED%99%94%EC%9D%B4%EB%B2%A4%ED%8A%B8) - [再生イベント](/docs/ja/vpe-ios#%EC%9E%AC%EC%83%9D%EC%9D%B4%EB%B2%A4%ED%8A%B8) - [一時停止イベント](/docs/ja/vpe-ios#%EC%9D%BC%EC%8B%9C%EC%A0%95%EC%A7%80%EC%9D%B4%EB%B2%A4%ED%8A%B8) - [再生完了イベント](/docs/ja/vpe-ios#%EC%9E%AC%EC%83%9D%EC%99%84%EB%A3%8C%EC%9D%B4%EB%B2%A4%ED%8A%B8) - [フルスクリーンイベント](/docs/ja/vpe-ios#%EC%A0%84%EC%B2%B4%ED%99%94%EB%A9%B4%EC%9D%B4%EB%B2%A4%ED%8A%B8) #### 横向きモード有効化イベント デバイスを横向きに切り替える際にイベントを発生させるには、`NCPlayerIsLandscape` メソッドを利用して次のように設定します。 ``` import NCPlayerSDK ... class ViewController: UIViewController, NCPlayerDelegate{ ... func NCPlayerIsLandscape(state: Bool) { } } ``` #### スクリーンキャプチャ検知イベント(iOS専用) スクリーンキャプチャ時にイベントを発生させるには、`NCPlayerIsCaptured` メソッドを利用して次のように設定します。 ``` import NCPlayerSDK ... class ViewController: UIViewController, NCPlayerDelegate{ ... func NCPlayerIsCaptured(state: Bool) { } } ``` #### OS画面録画検知イベント(iOS専用) 画面録画時にイベントを発生させるには、`NCPlayerIsRecording` メソッドを利用して次のように設定します。 ``` import NCPlayerSDK ... class ViewController: UIViewController, NCPlayerDelegate{ ... func NCPlayerIsRecording(state: Bool) { } } ``` #### TimeUpdateイベント 再生時間変化検知時にイベントを発生させるには、`NCPlayerOnTimeUpdate` メソッドを利用して次のように設定します。 ``` import NCPlayerSDK ... class ViewController: UIViewController, NCPlayerDelegate{ ... func NCPlayerOnTimeUpdate(data: Dictionary?) { //data = ["duration": 117, "percent": 31.26565391099825, "viewingTime": 37, "currentTime": 37, "sourceType": vod] } } ``` 参考 各プロパティの詳しい説明は、[timeupdateスクリプト](/docs/ja/vpe-web#timeupdate%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8)をご参照ください。 #### PrevTrackイベント プレイリストの前の動画へ移動する際にイベントを発生させるには、`NCPlayerOnPrevTrack` メソッドを利用して次のように設定します。 ``` import NCPlayerSDK ... class ViewController: UIViewController, NCPlayerDelegate{ ... func NCPlayerOnPrevTrack(data: Dictionary?) { } } ``` 参考 各プロパティの詳しい説明は、[prevTrackスクリプト](/docs/ja/vpe-web#prevTrack%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8)をご参照ください。 #### NextTrackイベント プレイリストの次の動画へ移動する際にイベントを発生させるには、`NCPlayerOnNextTrack` メソッドを利用して次のように設定します。 ``` import NCPlayerSDK ... class ViewController: UIViewController, NCPlayerDelegate{ ... func NCPlayerOnNextTrack(data: Dictionary?) { } } ``` 参考 各プロパティの詳しい説明は、[nextTrackスクリプト](/docs/ja/vpe-web#nextTrack%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8)をご参照ください。 #### コントロールバー有効化イベント プレイヤーでコントロールバーを有効/無効にする際にイベントを発生させるには、`NCPlayerOnControlbarActive` メソッドを利用して次のように設定します。 ``` import NCPlayerSDK ... class ViewController: UIViewController, NCPlayerDelegate{ ... func NCPlayerOnControlbarActive(active: Bool) { // active: true , false } } ``` #### 再生イベント プレイヤーで動画を再生する際にイベントを発生させるには、`NCPlayerOnPlay` メソッドを利用して次のように設定します。 ``` import NCPlayerSDK ... class ViewController: UIViewController, NCPlayerDelegate{ ... func NCPlayerOnPlay() { } } ``` #### 一時停止イベント プレイヤーで動画を一時停止する際にイベントを発生させるには、`NCPlayerOnPause` メソッドを利用して次のように設定します。 ``` import NCPlayerSDK ... class ViewController: UIViewController, NCPlayerDelegate{ ... func NCPlayerOnPause() { } } ``` #### 再生完了イベント プレイヤーで動画再生が完了する際にイベントを発生させるには、`NCPlayerOnEnd` メソッドを利用して次のように設定します。 ``` import NCPlayerSDK ... class ViewController: UIViewController, NCPlayerDelegate{ ... func NCPlayerOnEnd() { } } ``` #### フルスクリーンイベント フルスクリーンへの切り替え時にイベントを発生させることができ、デバイス回転方向に応じてフルスクリーンに切り替えするように設定できます。 プレイヤーをフルスクリーンに切り替える際にイベントを発生させるには、`NCPlayerOnFullscreen` メソッドを利用して次のように設定します。 ``` import NCPlayerSDK ... class ViewController: UIViewController, NCPlayerDelegate{ ... // フルスクリーンが解除した時に発生するイベント func NCPlayerOnFullscreenOff() { } // フルスクリーンに切り替わった時に発生するイベント func NCPlayerOnFullscreenOn() { } // フルスクリーンに切り替わった時の区別 true/false func NCPlayerOnFullscreen(state: Bool?) { } } ``` ボタンまたはデバイスの回転方向を検知してフルスクリーンに切り替えるように設定するには、`NCPlayerRequestOrientation` メソッドを次のように設定します。 ``` import NCPlayerSDK ... class ViewController: UIViewController, NCPlayerDelegate{ var currentOrientationMask: UIInterfaceOrientationMask = .portrait var currentOrientation: UIInterfaceOrientation = .portrait // 横向きにするとフルスクリーン、縦向きにすると解除 func NCPlayerRequestOrientation(orientation: String) { if (orientation == "landscape") { currentOrientationMask = .landscape currentOrientation = .landscapeRight } else { currentOrientationMask = .portrait currentOrientation = .portrait } applyOrientation(orientation: currentOrientation) } override var supportedInterfaceOrientations: UIInterfaceOrientationMask { return currentOrientationMask; } override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation { return currentOrientation; } override var prefersStatusBarHidden: Bool { return currentOrientation.isLandscape } } extension NSLayoutConstraint { func applyAspectRatio(view: UIView, ratio: CGFloat) -> NSLayoutConstraint { let newConstraint = NSLayoutConstraint(item: self.firstItem!, attribute: self.firstAttribute, relatedBy: self.relation, toItem: self.secondItem, attribute: self.secondAttribute, multiplier: ratio, constant: self.constant) view.removeConstraint(self) view.addConstraint(newConstraint) view.layoutIfNeeded() return newConstraint } } } ``` デバイスの回転方向を検知してフルスクリーンに切り替えるように設定するには、`NCPlayerIsLandscape` メソッドを次のように設定します。 ``` import NCPlayerSDK ... class ViewController: UIViewController, NCPlayerDelegate{ var currentOrientationMask: UIInterfaceOrientationMask = .portrait var currentOrientation: UIInterfaceOrientation = .portrait func NCPlayerIsLandscape(state: Bool) { if state { currentOrientationMask = .landscape currentOrientation = UIDevice.current.orientation == .landscapeLeft ? .landscapeRight : .landscapeLeft }else{ currentOrientationMask = .portrait currentOrientation = .portrait } applyOrientation(orientation: currentOrientation) } override var supportedInterfaceOrientations: UIInterfaceOrientationMask { return currentOrientationMask; } override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation { return currentOrientation; } override var prefersStatusBarHidden: Bool { return currentOrientation.isLandscape } } extension NSLayoutConstraint { func applyAspectRatio(view: UIView, ratio: CGFloat) -> NSLayoutConstraint { let newConstraint = NSLayoutConstraint(item: self.firstItem!, attribute: self.firstAttribute, relatedBy: self.relation, toItem: self.secondItem, attribute: self.secondAttribute, multiplier: ratio, constant: self.constant) view.removeConstraint(self) view.addConstraint(newConstraint) view.layoutIfNeeded() return newConstraint } } } ```