zoukankan      html  css  js  c++  java
  • iOS端VR视频播放(转自简书http://www.jianshu.com/p/1ee1a0d1d320)

    下面是我看了谷歌的一个VR在iOS端开发的文档写的一个demo。

    第一步是需要用cocoaPods导入谷歌开发的一个第三方:CardboardSDK,怎么导入就不多说了,这里需要注意的一点是谷歌方面的第三方导入需要翻墙,一般的翻墙软件是不可行的,需要用到VPN进行翻墙。

    第二步,在导入第三方后在ViewController.m文件导入 #import “GCSVideoView.h”

    遵循代理:GCSVideoViewDelegate

    初始化:

    GCSVideoView *_VRPlayerView = [[GCSVideoView alloc]initWithFrame:self.view.bounds];

    确认代理:_VRPlayerView.delegate = self;

    显示CardboardButton :

    _VRPlayerView.enableCardboardButton = YES;

    是否可以全屏 :

    _VRPlayerView.enableFullscreenButton = YES;

    在GCSVideoView上加载VR视频 :

    [_VRPlayerView loadFromUrl:[NSURLURLWithString:@"http://v1.mukewang.com/a45016f4-08d6-4277-abe6-bcfd5244c201/L.mp4"]];

    实现代理方法

    #pragma mark ----GCSVideoViewDelegate----//GCSVideoView的点击事件-(void)widgetViewDidTap:(GCSWidgetView *)widgetView{

    if(_isPaused) {     

      [_VRPlayerView resume]; 

      }else{     

      [_VRPlayerView pause]; 

      }

        _isPaused = !_isPaused;}

    //视频播放到某个位置时触发事件

    -(void)videoView:(GCSVideoView *)videoView didUpdatePosition:(NSTimeInterval)position{

    if(position == videoView.duration) { 

          [_VRPlayerView seekTo:0];   

        [_VRPlayerView resume];   

         }

    }

    //视频播放失败-(void)widgetView:(GCSWidgetView *)widgetView didFailToLoadContent:(id)content withErrorMessage:(NSString*)errorMessage{

    NSLog(@"播放错误");

    }

    应大家的要求,我写了个DEMO上传到了github,有需要的可以去下载来看看。希望大家能给个星哦,顺便给这篇文章点个赞吧。以后会更新更多的技术贴,谢谢大家支持。   VRDemo

  • 相关阅读:
    以AO方式给SceneControl控件设置BaseHeight
    TreeView只能选中一个节点
    Excel导出DataTable
    TOCControl右键菜单
    Arcgis Engine符号化相关
    shapefile文件锁定问题
    ArcGIS符号库serverstyle文件编辑注意事项
    CentOS运维常用命令
    常用shell
    javascript浮点数相减、相乘出现一长串小数
  • 原文地址:https://www.cnblogs.com/Hakim/p/6726619.html
Copyright © 2011-2022 走看看