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

  • 相关阅读:
    《C#高级编程》学习笔记------C#中的委托和事件(续)
    .NET Reflector 7.6.1.824 Edition .NET程序反编译神器(附插件安装教程2012-10-13更新) 完全破解+使用教程
    《C#高级编程》学习笔记------C#中的事件和委托
    TensorFlow+实战Google深度学习框架学习笔记(5)----神经网络训练步骤
    Tensorflow学习笔记----模型的保存和读取(4)
    Tensorflow学习笔记----基础(3)
    Tools
    English Learning
    Tools
    Testing
  • 原文地址:https://www.cnblogs.com/Hakim/p/6726619.html
Copyright © 2011-2022 走看看