PageSourceSearch

https://www.vdocipher.com/docs/assets/js/c1ea3414.b9f4eaf4.js

js vdocipher.com collected 2026-09-24 17:17:33 UTC 13,334 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkdocusaurus=self.webpackChunkdocusaurus||[]).push([[5647],{28317:(e,n,t)=>{t.d(n,{A:()=>r});const r=t.p+"assets/images/framework-section-in-xcode-1b65b41b9cafb780392bb6eed187fa15.png"},28453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>l});var r=t(96540);const o={},a=r.createContext(o);function i(e){const n=r.useContext(a);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:i(e.components),r.createElement(a.Provider,{value:n},e.children)}},51755:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>s,contentTitle:()=>i,default:()=>h,frontMatter:()=>a,metadata:()=>l,toc:()=>d});var r=t(74848),o=t(28453);const a={title:"iOS Native Video SDK",sidebar_label:"Getting started"},i=void 0,l={id:"mobile/ios/getting-started",title:"iOS Native Video SDK",description:"Latest version: 2.9.4",source:"@site/docs/mobile/ios/getting-started.md",sourceDirName:"mobile/ios",slug:"/mobile/ios/getting-started",permalink:"/docs/mobile/ios/getting-started",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{title:"iOS Native Video SDK",sidebar_label:"Getting started"},sidebar:"mobile",previous:{title:"External Playback",permalink:"/docs/mobile/android/examples/external-url"},next:{title:"Downloading videos for offline",permalink:"/docs/mobile/ios/offline"}},s={},d=[{value:"Installation",id:"installation",level:2},{value:"Swift Package Manager",id:"swift-package-manager",level:3},{value:"CocoaPods",id:"cocoapods",level:3},{value:"Static xcframework",id:"static-xcframework",level:3},{value:"Setting up in code",id:"setting-up-in-code",level:2},{value:"0. Integrating Player View",id:"0-integrating-player-view",level:3},{value:"Integrate Player With UI Controls",id:"integrate-player-with-ui-controls",level:4},{value:"Alternative: Player Without UI Controls/ Default Controls",id:"alternative-player-without-ui-controls-default-controls",level:4},{value:"1. Playback delegate",id:"1-playback-delegate",level:3},{value:"2. Get otp, playbackInfo &amp; video-id from your backend",id:"2-get-otp-playbackinfo--video-id-from-your-backend",level:3},{value:"3. Create an asset",id:"3-create-an-asset",level:3},{value:"4. Call the <code>playOnline</code> method",id:"4-call-the-playonline-method",level:3},{value:"Next Steps",id:"next-steps",level:2}];function c(e){const n={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",h4:"h4",img:"img",li:"li",mdxAdmonitionTitle:"mdxAdmonitionTitle",ol:"ol",p:"p",pre:"pre",strong:"strong",...(0,o.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"Latest version: 2.9.4"})}),"\n",(0,r.jsx)(n.h2,{id:"installation",children:"Installation"}),"\n",(0,r.jsxs)(n.p,{children:["VdoFramework supports ",(0,r.jsx)(n.a,{href:"https://www.swift.org/package-manager/",children:"Swift Package Manager"}),", ",(0,r.jsx)(n.a,{href:"https://cocoapods.org",children:"CocoaPods"})," and static xcframework"]}),"\n",(0,r.jsx)(n.h3,{id:"swift-package-manager",children:"Swift Package Manager"}),"\n",(0,r.jsx)(n.p,{children:"Go to Xcode 26.0 or above > File > Add Packages and search the\nfollowing URL:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:"https://github.com/VdoCipher/swift-pm-repo\n"})}),"\n",(0,r.jsx)(n.p,{children:"Select 'Up to Next Major Version' in Dependency Rule and set value as '2.9.4'. We will be following semantic versioning for the version numbers."}),"\n",(0,r.jsx)(n.h3,{id:"cocoapods",children:"CocoaPods"}),"\n",(0,r.jsx)(n.p,{children:"Add the pod to your Podfile:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-swift",children:"pod 'VdoFramework'\n"})}),"\n",(0,r.jsx)(n.p,{children:"And then run:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-swift",children:"pod install\n"})}),"\n",(0,r.jsx)(n.p,{children:"After installing the cocoapod into your project import VdoFramework with"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-swift",children:"import VdoFramework\n"})}),"\n",(0,r.jsx)(n.h3,{id:"static-xcframework",children:"Static xcframework"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://vdocipher.s3.amazonaws.com/archive/VdoFramework-2.9.4.xcframework.zip",children:"Download VdoFramework-2.9.4.xcframework.zip"})}),"\n",(0,r.jsxs)(n.ol,{children:["\n",(0,r.jsxs)(n.li,{children:["Download the zip file and open it to get the folder called ",(0,r.jsx)(n.code,{children:"VdoFramework.xcframework"}),"."]}),"\n",(0,r.jsx)(n.li,{children:'Drag the xcframework folder in the "Frameworks, Libraries and Embedded Content"'}),"\n",(0,r.jsxs)(n.li,{children:["Import the framework in the swift file where you like to use. You will need ",(0,r.jsx)(n.code,{children:"AVFoundation"}),". ",(0,r.jsx)(n.code,{children:"AVKit"})," is only needed\nwhen using with ",(0,r.jsx)(n.code,{children:"AVPlayerViewController"})]}),"\n",(0,r.jsx)(n.li,{children:"Make sure your application deployment target is 11.2 or newer."}),"\n"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-swift",children:"import VdoFramework\nimport AVFoundation\n"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"Framework installation",src:t(28317).A+"",width:"2306",height:"1344"})}),"\n",(0,r.jsx)(n.admonition,{title:"possible mistake",type:"note",children:(0,r.jsxs)(n.p,{children:["There are folders named Vdocipher.framework inside but you shouldn't use those directly. Make sure to drag the entire\nxcframework folder. Do\nnot place the framework folder directly in the\nfile-explorer. This will not work for ",(0,r.jsx)(n.code,{children:"xcframework"}),"."]})}),"\n",(0,r.jsxs)(n.admonition,{type:"note",children:[(0,r.jsxs)(n.mdxAdmonitionTitle,{children:["What is ",(0,r.jsx)(n.code,{children:"xcframework"}),"?"]}),(0,r.jsx)(n.p,{children:"An XCFramework is a distributable binary package created by Xcode that c
1ontains variants of a framework or library so that it can be used on multiple platforms (iOS, macOS, tvOS, and watchOS), including Simulator builds."}),(0,r.jsx)(n.p,{children:"XCFramework allows to make a single distribution which can work on different swift versions."})]}),"\n",(0,r.jsx)(n.h2,{id:"setting-up-in-code",children:"Setting up in code"}),"\n",(0,r.jsx)(n.h3,{id:"0-integrating-player-view",children:"0. Integrating Player View"}),"\n",(0,r.jsx)(n.p,{children:"VdoCipher provides two methods for integrating player into your application:"}),"\n",(0,r.jsx)(n.h4,{id:"integrate-player-with-ui-controls",children:"Integrate Player With UI Controls"}),"\n",(0,r.jsx)(n.p,{children:"You can fetch the player view controller from VdoCipher class,"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-swift",children:"let vdoPlayerController: UIViewController = VdoCipher.getVdoPlayerViewController()\n"})}),"\n",(0,r.jsxs)(n.p,{children:["and present that controller on top of another ",(0,r.jsx)(n.code,{children:"UIViewController"})," for full screen player view."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-swift",children:"self.present(vdoPlayerController, animated: true)\n"})}),"\n",(0,r.jsx)(n.p,{children:"Or you can also push it in the navigation controller stack."}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-swift",children:"self.navigationController?.pushViewController(vdoPlayerController, animated: true)\n"})}),"\n",(0,r.jsx)(n.p,{children:"This is the fastest and easiest way to integrate the player with controls into your application. This includes a prebuilt UI for the player with ample features and functionality."}),"\n",(0,r.jsx)(n.h4,{id:"alternative-player-without-ui-controls-default-controls",children:"Alternative: Player Without UI Controls/ Default Controls"}),"\n",(0,r.jsxs)(n.p,{children:["With storyboards, use ",(0,r.jsx)(n.a,{href:"https://developer.apple.com/documentation/avkit/avplayerviewcontroller",children:"AVPlayerViewController"}),"\nfor native (default) controls and\n",(0,r.jsx)(n.a,{href:"https://developer.apple.com/documentation/avfoundation/avplayerlayer",children:"AVPlayerLayer"})," for player without native\ncontrols. If you use ",(0,r.jsx)(n.code,{children:"AVPlayerLayer"}),", then you will need to create your own controls."]}),"\n",(0,r.jsxs)(n.p,{children:["For SwiftUI, you can skip to ",(0,r.jsx)(n.a,{href:"/mobile/ios/swiftUI",children:"SwiftUI Integration"})]}),"\n",(0,r.jsx)(n.h3,{id:"1-playback-delegate",children:"1. Playback delegate"}),"\n",(0,r.jsxs)(n.p,{children:["You need a delegate to listen for player setup events. The methods will be\ncalled when switching assets or when the video player is ready to play. This is\nthe only way to get the reference to the AVPlayer. Use this object to do much\nmore with\n",(0,r.jsx)(n.a,{href:"https://developer.apple.com/documentation/avfoundation/avplayer",children:"AVPlayer"})," API."]}),"\n",(0,r.jsxs)(n.p,{children:["Use the ",(0,r.jsx)(n.code,{children:"playerReadyToPlay"})," to update your UI or start playing the video."]}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"playerCurrentItemDidChange"})," will be useful when you are creating a playlist,\nand the next video gets loaded after a call to ",(0,r.jsx)(n.code,{children:"playOnline()"})," or ",(0,r.jsx)(n.code,{children:"playOffline()"}),"\nmethods."]}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"streamLoadError"})," will be useful to identify an error when a playback is initiated."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-swift",children:"extension ViewController {\n    func streamPlaybackManager(playerReadyToPlay player: AVPlayer) {\n        // player is ready to play\n        player.play()\n    }\n\n    func streamPlaybackManager(playerCurrentItemDidChange player: AVPlayer) {\n        /// player current item has changed, use this to set to destination from Step 0, only in case if you are using default `AVPlayerViewController` with default controls for playback.\n        playerViewController.player = player\n    }
1\n\n    func streamLoadError(error: VdoError) {\n        // Error occured while initiating playback\n    }\n}\n"})}),"\n",(0,r.jsx)(n.p,{children:"Connect it with your class"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-swift",children:"// create a delegate for tracking player state\nVdoCipher.setPlaybackDelegate(delegate: self)\n"})}),"\n",(0,r.jsx)(n.h3,{id:"2-get-otp-playbackinfo--video-id-from-your-backend",children:"2. Get otp, playbackInfo & video-id from your backend"}),"\n",(0,r.jsxs)(n.p,{children:["Playing vdocipher hosted videos requires these three parameters to\nauthenticate every playback session. Ask the backend to provide the\nfollowing scheme at the least. The backend application will use\n",(0,r.jsx)(n.a,{href:"/server/playbackauth/otp",children:"this API"})," to get this information."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-json",children:'{\n  "otp": "____",\n  "playbackInfo": "____",\n  "videoId": "_____"\n}\n'})}),"\n",(0,r.jsx)(n.admonition,{title:"Must not be done within app",type:"note",children:(0,r.jsx)(n.p,{children:"You must not implement the OTP generating API call from within the\napplication. Making any API call requires the API secret key. Putting this\non the app means that anyone can see your keys. Consider your secret API\nkeys like they are passwords."})}),"\n",(0,r.jsx)(n.h3,{id:"3-create-an-asset",children:"3. Create an asset"}),"\n",(0,r.jsx)(n.p,{children:"Create an asset using the video-id"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-swift",children:"// create a new asset\nVdoAsset.createAsset(videoId: videoId) { asset, error in\n    if let error = error\n    {\n        // Remove buffering icon and show error\n    }\n    else\n    {\n        self.asset = asset // keep this asset reference for your use\n        DispatchQueue.main.async {\n        let vdoPlayerController: VdoPlayerViewController = VdoCipher.getVdoPlayerViewController()\n        self.present(vdoPlayerController, animated: true)\n\n        /** If using your own custom controls on top of AVPlayerlayer,\n        then enable the UI for playing. Remove any buffering icon if showing.\n        self.playOnlineButton.isEnabled = true\n        */\n        }\n    }\n}\n"})}),"\n",(0,r.jsx)(n.h3,{id:""}),"\n",(0,r.jsxs)(n.h3,{id:"4-call-the-playonline-method",children:["4. Call the ",(0,r.jsx)(n.code,{children:"playOnline"})," method"]}),"\n",(0,r.jsx)(n.p,{children:"Use the asset reference generated in Step 2 to play video online"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-swift",children:"self.asset.playOnline(otp: otp, playbackInfo: playbackInfo)\n"})}),"\n",(0,r.jsx)(n.h2,{id:"next-steps",children:"Next Steps"}),"\n",(0,r.jsx)(n.p,{children:"The video player should be working fine now. For the next steps, you can\nimplement custom controls if native controls does not meet your needs."}),"\n",(0,r.jsx)(n.p,{children:"For downloading offline, you can read the docs about offline setup."})]})}function h(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(c,{...e})}):c(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.