OS移动端简介与对接

2018-12-25 18:51 [复制链接] 90 0

Video++ OS简介
OS_Lua 是在LuaView开源项目基础上,开发的一套视频互动对接层,其初衷是为了提升移动端互动模块动态化能力,同时做到Android、iOS业务代码共用,减少同一业务的人员重复投入。
目前OS_Lua已经完成云图和中插模板,使用OS_Lua的客户端能够具备动态化能力,做到bug随时修,业务随时上,且在硬件交互,动画等功能上提供比H5更好的体验。
OS_Lua 使用Lua语言进行代码编写,目前支持两个端:Android和iOS。Android 端使用LuaJ引擎,iOS端使用LuaC引擎。

Video++ iOS互动层对接SDK集成
有两种方式将Video++互动层添加到你的工程:
  • 使用CocoaPods
  • 手动添加framework


使用COCOSPODS
CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the Get Started section for more details.

PODFILE
  1. <ol class="linenums" style="box-sizing: border-box; padding-left: 5px; color: rgb(153, 153, 153); font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 13.6px; white-space: pre-wrap;"><li class="L0" style="list-style-type: none; box-sizing: border-box; background-color: rgb(252, 252, 252);"><code style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">platform </span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">:</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">ios</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">,</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);"> </span><span class="str" style="box-sizing: border-box; color: rgb(0, 136, 0);">'8.0'</span></code></li><li class="L1" style="list-style-type: none; box-sizing: border-box; background: rgb(252, 252, 252);"><code style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">pod </span><span class="str" style="box-sizing: border-box; color: rgb(0, 136, 0);">'VideoPls-iOS-SDK'</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">,</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);"> </span><span class="str" style="box-sizing: border-box; color: rgb(0, 136, 0);">'~> 1.0'</span></code></li></ol>
复制代码
如果你使用的是swift开发,请确保添加 use_frameworks!
  1. <ol class="linenums" style="box-sizing: border-box; padding-left: 5px; color: rgb(153, 153, 153); font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 13.6px; white-space: pre-wrap;"><li class="L0" style="list-style-type: none; box-sizing: border-box; background-color: rgb(252, 252, 252);"><code style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">platform </span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">:</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">ios</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">,</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);"> </span><span class="str" style="box-sizing: border-box; color: rgb(0, 136, 0);">'8.0'</span></code></li><li class="L1" style="list-style-type: none; box-sizing: border-box; background: rgb(252, 252, 252);"><code style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">use_frameworks</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">!</span></code></li></ol>
复制代码

手动添加FRAMEWORK
快速集成SDK

  • 将下载的SDK解压后导入您的工程中 (注:请务必在此步骤中选择“Create groups”单选按钮组, 因该SDK体积过大,不要勾选“Copy items if needed”。用这种方式仅引用该SDK,避免引起项目体积过大的问题)
    1-6.png
  • 设置项目的Framework Search Paths (注:由于我们采用了Reference的方式,所以此处必须在Framework Search Paths里面添加SDK在本机所在的路径,路径从Users开始),如图:
    1-6.png
  • 添加依赖库(Xcode 7 下 *.dylib 库后缀名更改为 *.tbd ),请确保已添加以下 依赖库:


  1. <ol class="linenums" style="box-sizing: border-box; padding-left: 5px; list-style-type: lower-roman; color: rgb(153, 153, 153); font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 13.6px; white-space: pre-wrap;"><li class="L0" style="list-style-type: none; box-sizing: border-box; background-color: rgb(252, 252, 252);"><code class="lang-js" style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">libz</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">.</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">tbd</span></code></li><li class="L1" style="list-style-type: none; box-sizing: border-box; background: rgb(252, 252, 252);"><code class="lang-js" style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">libsqlite3</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">.</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">tbd</span></code></li><li class="L2" style="list-style-type: none; box-sizing: border-box; background-color: rgb(252, 252, 252);"><code class="lang-js" style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="typ" style="box-sizing: border-box; color: rgb(102, 0, 102);">MediaPlayer</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">.</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">framework</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">,</span></code></li><li class="L3" style="list-style-type: none; box-sizing: border-box; background: rgb(252, 252, 252);"><code class="lang-js" style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="typ" style="box-sizing: border-box; color: rgb(102, 0, 102);">WebKit</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">.</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">framework</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">,</span></code></li><li class="L4" style="list-style-type: none; box-sizing: border-box; background-color: rgb(252, 252, 252);"><code class="lang-js" style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="typ" style="box-sizing: border-box; color: rgb(102, 0, 102);">ImageIO</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">.</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">framework</span></code></li><li class="L5" style="list-style-type: none; box-sizing: border-box; background: rgb(252, 252, 252);"><code class="lang-js" style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="typ" style="box-sizing: border-box; color: rgb(102, 0, 102);">Security</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">.</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">framework</span></code></li><li class="L6" style="list-style-type: none; box-sizing: border-box; background-color: rgb(252, 252, 252);"><code class="lang-js" style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="typ" style="box-sizing: border-box; color: rgb(102, 0, 102);">CoreMedia</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">.</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">framework</span></code></li><li class="L7" style="list-style-type: none; box-sizing: border-box; background: rgb(252, 252, 252);"><code class="lang-js" style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="typ" style="box-sizing: border-box; color: rgb(102, 0, 102);">AVFoundation</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">.</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">framework</span></code></li><li class="L8" style="list-style-type: none; box-sizing: border-box; background-color: rgb(252, 252, 252);"><code class="lang-js" style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="typ" style="box-sizing: border-box; color: rgb(102, 0, 102);">MobileCoreService</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">.</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">framework</span></code></li><li class="L9" style="list-style-type: none; box-sizing: border-box; background: rgb(252, 252, 252);"><code class="lang-js" style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="typ" style="box-sizing: border-box; color: rgb(102, 0, 102);">Accelerate</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">.</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">framework</span></code></li><li class="L0" style="list-style-type: none; box-sizing: border-box; background-color: rgb(252, 252, 252);"><code class="lang-js" style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="typ" style="box-sizing: border-box; color: rgb(102, 0, 102);">CoreTelephony</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">.</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">framework</span></code></li><li class="L1" style="list-style-type: none; box-sizing: border-box; background: rgb(252, 252, 252);"><code class="lang-js" style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="typ" style="box-sizing: border-box; color: rgb(102, 0, 102);">SystemConfiguration</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">.</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">framework</span></code></li><li class="L2" style="list-style-type: none; box-sizing: border-box; background-color: rgb(252, 252, 252);"><code class="lang-js" style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="typ" style="box-sizing: border-box; color: rgb(102, 0, 102);">AssetsLibrary</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">.</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">framework</span></code></li><li class="L3" style="list-style-type: none; box-sizing: border-box; background: rgb(252, 252, 252);"><code class="lang-js" style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="typ" style="box-sizing: border-box; color: rgb(102, 0, 102);">Photos</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">.</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">framework</span></code></li><li class="L4" style="list-style-type: none; box-sizing: border-box; background-color: rgb(252, 252, 252);"><code class="lang-js" style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="typ" style="box-sizing: border-box; color: rgb(102, 0, 102);">CoreData</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">.</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);">framework</span></code></li></ol>
复制代码

  • 设置 Other Linker flags.
    在 Other Linker Flags 中添加 –ObjC,如图(注意:如果项目中加载多个静态库有冲突,并使用了-force_load 的,不能添加-ObjC,且相 应此库也需要加入 force_load,对应路径需要指定到 VideoPlsCytronSDK.framework/VideoPlsCytronSDK.h

1-6.png
  • 可能依赖的第三方库(具体视平台不同而不一致)


  1. <ol class="linenums" style="box-sizing: border-box; padding-left: 5px; color: rgb(153, 153, 153); font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 13.6px; white-space: pre-wrap;"><li class="L0" style="list-style-type: none; box-sizing: border-box; background-color: rgb(252, 252, 252);"><code style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="str" style="box-sizing: border-box; color: rgb(0, 136, 0);">'AFNetworking'</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">,</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);"> </span><span class="str" style="box-sizing: border-box; color: rgb(0, 136, 0);">'~>2.0'</span></code></li><li class="L1" style="list-style-type: none; box-sizing: border-box; background: rgb(252, 252, 252);"><code style="box-sizing: border-box; font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-size: 14px; background: 0px 0px; border-radius: 3px; border: none; display: inline; max-width: initial; overflow: initial; line-height: inherit; word-wrap: normal; color: rgb(221, 17, 68);"><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);"> </span><span class="str" style="box-sizing: border-box; color: rgb(0, 136, 0);">'SDWebImage'</span><span class="pun" style="box-sizing: border-box; color: rgb(102, 102, 0);">,</span><span class="pln" style="box-sizing: border-box; color: rgb(0, 0, 0);"> </span><span class="str" style="box-sizing: border-box; color: rgb(0, 136, 0);">'4.2.2'</span></code></li></ol>
复制代码

互动层对接SDK初始化

在 AppDelegate.m 文件中导入 <VideoPlsInterfaceControllerSDK/VPIConfigSDK.h> ,并在 application:didFinishLaunchingWithOptions: 方法中初始化SDK。
示例代码:
#import <VideoPlsInterfaceControllerSDK/VPIConfigSDK.h>- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions{     //other code    [VPIConfigSDK initSDK];    //other code}对接VPINTERFACECONTROLLER
  • 根据需要接入的SDK创建VPInterfaceControllerConfig,将SDK需要的信息配置在config中。

    • identifier 为点播视频url或直播房间号
    • types 为视频类型(点播or直播),默认为点播

  • 利用生成的config初始化InterfaceController, interfaceController.view就是生成的互动层,将这个view添加到播放器层之上就可以了。根据接入的SDK的需求可能有一些特殊的接口,放在相应的文件中,如需要调用,将对应文件import就可以调用了,详细作用请看注释。


  1. //配置信息
  2. VPInterfaceControllerConfig *config = [[VPInterfaceControllerConfig alloc] init];
  3. config.identifier = videoUrl; //or roomId
  4. config.types = VPInterfaceControllerTypeVideoOS; //or VPInterfaceControllerTypeLiveOS
  5. //扩展信息
  6. NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:0];
  7. [dict setObject:@"lol" forKey:@"category"];
  8. config.extendDict = dict;

  9. //播放器size
  10. CGSize screenSize = [UIScreen mainScreen].bounds.size;
  11. VPIVideoPlayerSize *videoPlayerSize = [[VPIVideoPlayerSize alloc] init];
  12. videoPlayerSize.portraitFullScreenWidth = screenSize.width < screenSize.height ? screenSize.width : screenSize.height;
  13. videoPlayerSize.portraitFullScreenHeight = screenSize.width < screenSize.height ? screenSize.height : screenSize.width;
  14. videoPlayerSize.portraitSmallScreenHeight = videoPlayerSize.portraitFullScreenWidth * 9.0/16.0;
  15. videoPlayerSize.portraitSmallScreenOriginY = 0.0;

  16. VPInterfaceController  *interfaceController = [[VPInterfaceController alloc] initWithFrame:self.view.bounds config:config videoPlayerSize:videoPlayerSize];

  17. interfaceController.delegate = self;
  18. interfaceController.userDelegate = self;
  19. interfaceController.videoPlayerDelegate = self;

  20. [self.view addSubview:interfaceController.view];

  21. [interfaceController start];

  22. ...
  23. //结束时,调用stop
  24. [interfaceController stop];

复制代码
  • 接着,设置当前互动层显示区域,代码如下所示
    [interfaceController notifyVideoScreenChanged:type];
    • 互动层加载完成、视频加载完成,建议调用更新方法,旋转横竖屏之后必须调用更新方法

  • 全部完成之后调用 start ,开启互动层。
  • 获取互动层状态信息需要遵守VPInterfaceStatusNotifyDelegate协议,详见注释
  • 如需深度对接账号系统需要遵守VPUPUserLoginInterface协议,详见注释
  • 如退出播放页面或直播间,调用stop方法


用户对接相关
  • VPIUserLoginInterface 和 VPIUserInfo, VPIUserInfo用来组装用户实例, VPIUserLoginInterface 用来获取关于用户数据的回调;

  • - (VPIUserInfo *)vp_getUserInfo 通过平台方得到你们的userInfo
  • - (void)vp_userLoginedVPIUserInfo *) userInfo 通过sdk登陆后会给你们对应的用户信息
  • - (void)vp_requireLoginvoid (^)(VPIUserInfo *userInfo))completeBlock 登陆成功后组成userInfo使用completeBlock(userInfo)完成回调


获取互动层状态信息
VPInterfaceStatusNotifyDelegate - (void)vp_interfaceActionNotify, 会回传互动层状态和需要的操作
  • adID 为广告的唯一标识
  • adName 为广告名
  • eventType 为广告触发的事件,包括展示、点击、关闭等
  • actionType 为对接方需要做的操作,包括打开外链,暂停视频,播放视频
  • url 为外链地址


示例如下:
  1. - (void)vp_interfaceActionNotify:(NSDictionary *)actionDictionary {

  2.         VPIActionType actionType = (VPIActionType)[[actionDictionary objectForKey:@"actionType"] integerValue];
  3.         switch (actionType) {
  4.             case VPIActionTypeOpenUrl:
  5.                 if ([actionDictionary objectForKey:@"url"]) {
  6.                     VPWebViewController *webViewController = [[VPWebViewController alloc] init];
  7.                     __weak typeof(self) weakSelf = self;
  8.                     [webViewController loadUrl:[actionDictionary objectForKey:@"url"] close:^{
  9.                         __strong typeof(self) strongSelf = weakSelf;
  10.                         [strongSelf->_interfaceController platformCloseActionWebView];
  11.                     }];
  12.                     [self presentViewController:webViewController animated:YES completion:nil];
  13.                 }
  14.                 break;
  15.             case VPIActionTypePauseVideo:
  16.                 [_player pause];
  17.                 _mediaControlView.hidden = YES;
  18.                 break;
  19.             case VPIActionTypePlayVideo:
  20.                 [_player play];
  21.                 _mediaControlView.hidden = NO;
  22.                 break;

  23.             default:
  24.                 break;
  25.         }

  26.         VPIEventType eventType = (VPIEventType)[[actionDictionary objectForKey:@"eventType"] integerValue];
  27.         if (eventType == VPIEventTypeBack) {
  28.             [self dismissPlayerViewController];
  29.         }
  30.         }
复制代码


注意事项

  • VPInterfaceControllerConfig identifier参数为视频的标识(原url),可以用url作为参数 或 使用拼接 ID的方式来识别(前提为与pc对接并通过)。
  • 文档中的代码仅供参考,实际参数请根据项目自行配置。
  • 互动层会向下层 view 发放点击手势,不用担心控制器界面会被阻挡手势。
  • 请将互动层置于合适位置以防阻挡手势。
  • 最佳位置为加载控制栏的下方,并且于手势层的上方,请不要将 cytronView 放 入包含手势操作的 View 中。
  • SDK目前支持系统为 ios8 以上。
  • 存在bundle包时请将bundle包放入资源文件中,使SDK能正常调用。



Demo演示

为了方便测试数据,在Demo中有一份演示的投放数据adInfo.json,包含云图和中插投放的数据,数据格式如下:
  1. {
  2.     "totalRecord": 2,
  3.     "resMsg": "处理成功",
  4.     "attachInfo": null,
  5.     "resCode": "00",
  6.     "launchInfoList": [{
  7.                        "id": "cd0d5140-4922-442a-87f6-af3aa74c5a5e",
  8.                        "template": "os_cloud.lua",
  9.                        "videoStartTime": 10000,
  10.                        "videoEndTime": 31000,
  11.                        "clockStartTime": null,
  12.                        "clockEndTime": null,
  13.                        "duration": 20000,
  14.                        "data": {
  15.                        "positionY": 0.5,
  16.                        "isShowAds": true,
  17.                        "creativeName": "wp-sucai-008",
  18.                        "interactionTemplateId": 34,
  19.                        "imageUrl": "https://consolecdn.videojj.com/upload_img/5a193ce05e027500009bc40e.jpeg",
  20.                        "width": 0.1,
  21.                        "linkUrl": "https://www.baidu.com",
  22.                        "interactionTypeId": 53,
  23.                        "isShowClose": true,
  24.                        "ratio": 1,
  25.                        "positionX": 0.5,
  26.                        "needShowOnPortrait": true
  27.                        }
  28.                        }, {
  29.                        "id": "fdcc4b0a-03a7-4697-b64f-9c93b7d55409",
  30.                        "template": "os_wedge.lua",
  31.                        "videoStartTime": 5000,
  32.                        "videoEndTime": 23000,
  33.                        "clockStartTime": null,
  34.                        "clockEndTime": null,
  35.                        "duration": 20000,
  36.                        "data": {
  37.                        "isShowAds": true,
  38.                        "creativeName": "wp-wedge-001",
  39.                        "interactionTemplateId": 35,
  40.                        "isShowClose": true,
  41.                        "positionX": 0,
  42.                        "positionY": 0,
  43.                        "videoDuration": 60,
  44.                        "repeatTimes": 5,
  45.                        "isShowCountdown": true,
  46.                        "videoUrl": "http://qa-video.oss-cn-beijing.aliyuncs.com/mp4/xfxz0227tvc.mp4",
  47.                        "closeAfter": 10000,
  48.                        "width": 1,
  49.                        "linkUrl": "http://baidu.com",
  50.                        "interactionTypeId": 54,
  51.                        "ratio": 1,
  52.                        "needShowOnPortrait": true
  53.                        }
  54.                        }]
  55. }
复制代码
模拟投放操作流程,启动Demo App,点击点播,进入点播页面以后,点击右下角的按钮,在弹出的列表中,选择模拟,即可模拟投放数据。

Video++ Android互动层对接
SDK集成
有两种方式将Video++互动层添加到你的工程:
  • 使用项目依赖
  • 手动添加配置compile project(':venvy_pub')



使用GRADLE

repositories {
maven { url 'https://dl.bintray.com/videoli/maven/' }
}
dependencies {
implementation 'cn.com.videopls.pub:1.1.0'
}


兼容性

  1. 最低Android SDK :16
  2. 编译Android SDK :API 26或更高版本进行编译
复制代码


快速集成SDK

  • 使用Gradle集成,具体可参看SDK demo工程配置:
    repositories {
    mavenCentral()
    maven { url 'https://dl.bintray.com/videoli/maven/' }
    }
    dependencies {
    implementation 'cn.com.videopls.pub:1.1.0'
    }
  • 配置AndroidManifest.xml AndroidManifest.xml需要配置:
    <!-- 允许程序打开网络套接字 -->
    <uses-permission android:name="android.permission.INTERNET" />
  • 依赖的第三方库(具体视平台不同而不一致)


  1. compile "com.github.bumptech.glide:glide:3.7.0"
  2. compile "com.squareup.okhttp3:okhttp:3.8.0"
  3. compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2'
  4. annotationProcessor 'com.videoli:venvy_processor_compiler:1.0.1'
复制代码

互动层对接
SDK初始化

在 Application项目入口初始化SDK。
示例代码:
  1. VideoPlus.appCreate(Application application);
复制代码


对接VIDEOPLUSVIEW

  • 根据需要接入的SDK创建VideoPlusView,将SDK需要的信息配置在VideoPlusAdapter中。

    • videoID 为点播视频url或直播房间号
    • types 为视频类型(点播or直播),默认为点播

  • 初始化VideoPlusAdapter, VideoPlusView就是生成的互动层,将这个view添加到播放器层之上就可以了。SDK所需参数需复写VideoPlusAdapter相关方法,详细作用请看注释。


  1. //适配器VideoPlusAdapter (注:VideoView代表平台播放器,非必填)
  2. public class PlusAdapter extends VideoPlusAdapter {
  3. private VideoView player;

  4. public PlusAdapter(VideoView player) {
  5.     this.player = player;
  6. }
  7. //设置配置信息(注:setVideoID为点播视频ID,直播为房间号)

  8. /***
  9. * 设置配置信息
  10. * @return Provider配置信息类
  11. * 注:setVideoID(String videoId)为点播视频ID,直播为房间号
  12. *    setVideoType(VideoType videoType)为视频类型,VideoType.VIDEOOS点播 VideoType.LIVEOS直播
  13. */
  14. @Override
  15. public Provider createProvider() {
  16.     Provider provider = new Provider.Builder().setVideoID(String.valueOf(12)).setVideoType(VideoType.LIVEOS).build();
  17.     return provider;
  18. }

  19. /***
  20. *
  21. * @return IMediaControlListener 平台方播放器相关状态
  22. * 注:     getVideoSize(int horVideoWidth, int horVideoHeight, int verVideoWidth, int verVideoHeight, int portraitSmallScreenOriginY)为视频播放器横竖屏Size(必填)
  23. *         getCurrentPosition()为播放器当前播放时间(单位:毫秒),点播必须复写处理 直播无需此操作。
  24. */
  25. @Override
  26. public IMediaControlListener buildMediaController() {
  27.     return new VideoOSMediaController() {
  28.         @Override
  29.         public VideoPlayerSize getVideoSize() {
  30.             return new VideoPlayerSize(VenvyUIUtil.getScreenWidth(player.getContext()), VenvyUIUtil.getScreenHeight(player.getContext()),
  31.                     VenvyUIUtil.getScreenWidth(player.getContext()), 200, 0);
  32.         }

  33.         @Override
  34.         public long getCurrentPosition() {
  35.             return player != null ? player.getCurrentPosition() : -1;
  36.         }
  37.     };
  38. }

  39. //广告展示监听
  40. @Override
  41. public IWidgetShowListener buildWidgetShowListener() {
  42.     return super.buildWidgetShowListener();
  43. }

  44. //广告点击监听
  45. @Override
  46. public IWidgetClickListener buildWidgetClickListener() {
  47.     return super.buildWidgetClickListener();
  48. }

  49. //广告关闭监听
  50. @Override
  51. public IWidgetCloseListener buildWidgetCloseListener() {
  52.     return super.buildWidgetCloseListener();
  53. }

  54. //注册网络图片架构插件
  55. @Override
  56. public Class<? extends IImageLoader> buildImageLoader() {
  57.     return GlideImageLoader.class;
  58. }

  59. //注册网络请求架构插件
  60. @Override
  61. public Class<? extends IRequestConnect> buildConnectProvider() {
  62.     return cn.com.venvy.common.okhttp.OkHttpHelper.class;
  63. }

  64. //MQTT长连接结构插件
  65. @Override
  66. public Class<? extends ISocketConnect> buildSocketConnect() {
  67.     return VenvyMqtt.class;
  68. }
复制代码
详细调用请查看官网Demo项目。
```
  • 接着,设置设置适配器,代码如下所示


  1. VideoPlusView plusView = new VideoOsView(Context context);
  2. PlusAdapter plusAdapter = new PlusAdapter(MediaPlay play);
  3. plusView.setVideoOSAdapter(plusAdapter);
复制代码
  • 全部完成之后调用 start ,开启互动层。
    plusView.start();
  • 如退出播放页面或直播间,调用stop方法
    plusView.stop();
  • 其它
    6.1屏幕旋转处理:
    plusAdapter.notifyVideoScreenChanged(ScreenStatus.SMALL_VERTICAL);
    注(FULL_VERTICAL,SMALL_VERTICAL,LANDSCAPE分别代表平台方播放器界面调用)
    6.2中插视频广告暂停唤醒调用:
    plusAdapter.notifyMediaStatusChanged(MediaStatus.PLAYING);


  • adID 为广告的唯一标识
  • adName 为广告名
  • eventType 为广告触发的事件,包括展示、点击、关闭等
  • actionType 为对接方需要做的操作,包括打开外链,暂停视频,播放视频
  • url 为外链地址



注意事项

  • VideoPlusAdapter Provider参数为视频的标识(原url),可以用url作为参数 或 使用拼接 ID的方式来识别(前提为与pc对接并通过)。
  • 文档中的代码仅供参考,实际参数请根据项目自行配置。
  • 请将互动层置于合适位置以防阻挡事件分发操作。
  • 最佳位置为加载控制栏的下方,播放器上方。



Demo项目功能

1.Demo项目首页分为直播,点播,点击进入对应的平台。
2.进入默认开启播放器 开启互动。
3.底部提供俩个配置按钮,实现对互动广告的配置。
4.底部“模拟”按钮为测试本地广告功能。
5.底部右侧按钮为互动配置项,点击弹出配置项,可输入“素材名称”以“VideoID”(注:二选一即可)
其中输入“素材名称”为展示未投放的广告,输入“VideoID”展示已投放的广告。
OS移动端简介与对接流程及详细API链接:https://www.showdoc.cc/oslua?page_id=548543246385760



使用道具 举报 只看该作者 回复
最新评论 | 正序浏览
只看楼主|楼层直达:
*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|站点地图|Video++ ( 沪ICP备14042830-6号

Powered by video++

快速回复 返回顶部 返回列表