MD360Player4iOS 1.2.0

MD360Player4iOS 1.2.0

测试测试过
Lang语言 Obj-CObjective C
许可证 Apache 2
发布最新发布2017年9月

Asha 维护。




这是一个 iOS 上渲染 360 度全景视频的轻量级库。

预览

ScreenShot ScreenShot 原始 360 全景视频

Pod

pod 'MD360Player4iOS', '~> 1.0.0'

发布节点

1.0.0

  • make the switch mode public. switchInteractiveMode:(MDModeInteractive)interactiveMode and switchDisplayMode:(MDModeDisplay)displayMode and switchProjectionMode:(MDModeProjection)projectionMode
  • 添加圆形穹顶支持。
  • 添加立体支持。
  • 支持在运行时切换投影。

0.3.0

  • 修复关键错误(例如崩溃、黑屏)。
  • 支持自定义导演工厂。
  • 以更好的方式渲染多屏幕。
  • 添加触摸策略运动。
  • 添加 360 位图支持。

0.2.0

  • 支持捏合手势。

0.1.0

  • 运动传感器
  • 眼镜模式(多屏幕)
  • 易于使用
  • 与 AVPlayer 兼容。

用途

- (void)viewDidLoad {
    [super viewDidLoad];

    // Create a AVPlayerItem
    AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithURL:self.mURL];
    [self.player setPlayerItem:playerItem];
    [self.player play];

    /////////////////////////////////////////////////////// MDVRLibrary
    MDVRConfiguration* config = [MDVRLibrary createConfig];

    [config asVideo:playerItem];
    [config setContainer:self view:self.view];

    // optional
    [config displayMode:MDModeDisplayNormal];
    [config interactiveMode:MDModeInteractiveMotion];
    [config pinchEnabled:true];
    [config setDirectorFactory:self];

    self.vrLibrary = [config build];
    /////////////////////////////////////////////////////// MDVRLibrary
}

支持配置

typedef NS_ENUM(NSInteger, MDModeInteractive) {
    MDModeInteractiveTouch,
    MDModeInteractiveMotion,
    MDModeInteractiveMotionWithTouch,
};

typedef NS_ENUM(NSInteger, MDModeDisplay) {
    MDModeDisplayNormal,
    MDModeDisplayGlass,
};

启用捏合手势

/////////////////////////////////////////////////////// MDVRLibrary
MDVRConfiguration* config = [MDVRLibrary createConfig];

...
[config pinchEnabled:true];

self.vrLibrary = [config build];
/////////////////////////////////////////////////////// MDVRLibrary

自定义导演工厂

@interface VideoPlayerViewController ()<MD360DirectorFactory>
@end

@implementation VideoPlayerViewController
...
- (void) initPlayer{
    ...
    /////////////////////////////////////////////////////// MDVRLibrary
    MDVRConfiguration* config = [MDVRLibrary createConfig];
    ...
    [config setDirectorFactory:self]; // pass in the custom factory
    ...
    self.vrLibrary = [config build];
    /////////////////////////////////////////////////////// MDVRLibrary
}

// implement the MD360DirectorFactory protocol here.
- (MD360Director*) createDirector:(int) index{
    MD360Director* director = [[MD360Director alloc]init];
    switch (index) {
        case 1:
            [director setEyeX:-2.0f];
            [director setLookX:-2.0f];
            break;
        default:
            break;
    }
    return director;
}
...
@end

360 位图支持

@interface BitmapPlayerViewController ()<IMDImageProvider>

@end

@implementation BitmapPlayerViewController

...

- (void) initPlayer{
    ...
    /////////////////////////////////////////////////////// MDVRLibrary
    MDVRConfiguration* config = [MDVRLibrary createConfig];
    ...
    [config asImage:self];
    ...
    self.vrLibrary = [config build];
    /////////////////////////////////////////////////////// MDVRLibrary

}

// implement the IMDImageProvider protocol here.
-(void) onProvideImage:(id<TextureCallback>)callback{
    //
    SDWebImageDownloader *downloader = [SDWebImageDownloader sharedDownloader];
    [downloader downloadImageWithURL:self.mURL options:0
                            progress:^(NSInteger receivedSize, NSInteger expectedSize) {
                                NSLog(@"progress:%ld/%ld",receivedSize,expectedSize);
                                // progression tracking code
                            }
                           completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
                               if ( image && finished) {
                                   // do something with image
                                   if ([callback respondsToSelector:@selector(texture:)]) {
                                       [callback texture:image];
                                   }
                               }
                           }];


}

@end

查看 BitmapPlayerViewController.m

参考

Android 版本

MD360Player4Android

反馈

许可证

Copyright 2016 Asha

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   https://apache.ac.cn/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.