Coder Social home page Coder Social logo

mrcao2011 / md360player4ios Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ashqal/md360player4ios

0.0 1.0 1.0 10.89 MB

It is a lite library to render 360 degree panorama video for iOS. VR Player.

License: Apache License 2.0

Ruby 5.31% Objective-C 91.91% GLSL 2.77%

md360player4ios's Introduction

MD360Player4iOS

It is a lite library to render 360 degree panorama video for iOS.

Preview

ScreenShot ScreenShot
Raw 360 Panorama Video

Pod

pod 'MD360Player4iOS', '~> 1.0.0'

Release Node

1.0.0

  • make the switch mode public. switchInteractiveMode:(MDModeInteractive)interactiveMode and switchDisplayMode:(MDModeDisplay)displayMode and switchProjectionMode:(MDModeProjection)projectionMode
  • add dome support.
  • add stereo support.
  • switch projection in runtime support.

0.3.0

  • Fix crucial bug(e.g. crash, black screen).
  • Custom director factory support.
  • Better way to render multi screen.
  • Add motion with touch strategy.
  • Add 360 bitmap support.

0.2.0

  • Pinch gesture supported.

0.1.0

  • Motion Sensor
  • Glass Mode(multi-screen)
  • Easy to use
  • Worked with AVPlayer.

USAGE

- (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
}

Supported Configuration

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

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

Enabled Pinch Gesture

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

...
[config pinchEnabled:true];

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

Custom Director Factory

@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 Bitmap Support

@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

See BitmapPlayerViewController.m

Reference

Android Version

MD360Player4Android

Feedback

##LICENSE

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

   http://www.apache.org/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.

md360player4ios's People

Contributors

ashqal avatar

Watchers

mr.cao avatar

Forkers

mrzhangqiang

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.