Giter Site home page Giter Site logo

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.2.0

  • reactor the project.
  • barrel distortion supported.

1.1.3.beta

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 CustomDirectorFactory : NSObject<MD360DirectorFactory>
@end

@implementation CustomDirectorFactory

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

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

@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

akolov avatar ashqal avatar melbic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

md360player4ios's Issues

Uncontrolled movement with iPad Air

I encountered an issue with iPad Air devices. No matter the device orientation, the video initial orientation or the choice of video, the 360 view has an automatic and permanent rotation without moving the iPad. It doesn't happen with older versions of iPad. Just like if you were rotating the device slowly.

swift版本?

你的插件非常好! 请问有没有swift的版本?

莫名其妙 黑屏

  • (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];

    self.url = @"http://125.39.35.137/mp4files/301700000831C244/d8d913s460fub.cloudfront.net/krpanocloud/video/airpano/video-1920x960a.mp4";

    self.playerView = [[VIMVideoPlayerView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height)];
    [self.playerView setVideoFillMode:AVLayerVideoGravityResizeAspect];
    AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithURL:[NSURL URLWithString:self.url]];
    [self.playerView.player setPlayerItem:playerItem];
    [self.playerView.player play];

    MDVRConfiguration* config = [MDVRLibrary createConfig];

    [config displayMode:MDModeDisplayNormal];
    [config interactiveMode:MDModeInteractiveMotion];
    [config asVideo:playerItem];
    [config setContainer:self view:self.view];

    self.parseVideo = [config build];
    }

开始可以播放 ,后来加了个切换MODE的button ,过了几次黑屏了,去了button也不管用

vrlibraw.bundle 路徑是否有錯?

使用 pod 'MD360Player4iOS', '~> 1.0.0'
vrlibraw.bundle 路徑不正確,無法讀取 vrlibraw裡的檔案
ERROR while loading from file: Error Domain=NSCocoaErrorDomain Code=258 "檔案名稱無效。"

Hotpots and EyePicker

Hi! Thank you for this amazing library.

There is the possibility to add hotspots to the video view and an eye picker as in the Android version? If not, do you plan to include them?

Question iOS - Android

This a a question rather than an issue. Are there big differences between the two libraries? I have been following both repositories and it seems that Android is getting the whole attention, does that mean that iOS is good enough and Android needs more work?

Problem with view rotation

When moving the phone to the sides (with the motion sensors) and moving the finger up/down the view rotate to the sides and not up and down.

大格式图片不显示问题

你好,Asha,我替换了Demo中的那个jpg格式的360全景图,发现跑起来就是黑的,对比发现我那个图比你那个图大很多!

iOS较Android画面模糊

我们发现,使用MD360Player4iOS + ijkPlayer时,同样的视频源,iOS上要比Android上画面模糊一些,请问这个是什么原因呢?谢谢

Flat video player

Hello!

I have a problem when adding a new version of Bilibili IJKPlayer to the MD360Player. The video is not displayed as 360 but is just flat and plays like that.

Is there any code that needs to be adjusted to make it render on a sphere?

眼镜模式

在只支持竖屏的app中 怎么在眼镜模式中 使用横屏分割界面?

Require fix on MDVRHeader.h

Can you fix a define line from:

#define MDVR_RAW_PATH [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: MDVR_RAW_NAME]

to:

#define MDVR_RAW_PATH [[[NSBundle bundleForClass: [self class]] resourcePath] stringByAppendingPathComponent: MDVR_RAW_NAME]

With this modification, my 360 jpg viewer now works correctly!

请问MD360Director这个如何设置

您好,我看demo里用的工厂模式的设置,[director setEyeX:-2.0f];[director setLookX:-2.0f];这里的setEyeX和setLookX这两个参数是什么意思啊?谢谢

MDVRLibrary的实现博客

作者什么时候有时间会写一个博客来简单介绍一下这个库的实现原理吗,看了作者的源码,有点不太能看懂,最近想研究一下这个VR视频的处理,准备细细的研究一下源码,提升一下自己.

Dead-lock when set texture in main thread

Hi, I had this issue:

#pragma mark IMDImageProvider
-(void)onProvideImage:(id<TextureCallback>)callback {
    NSData * data = [NSData dataWithContentsOfURL:_imageURL];
    _image  = [UIImage imageWithData:data];
    // bug of MD360Player4iOS, if call this in main queue, dead-lock will happen
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        [callback texture:self.image];
    });
}

If I call [callback texture: _image] in main thread, it will fall into dead lock because

-(void) texture:(UIImage*)image{
    if (image == nil) {
        return;
    }
    dispatch_sync(dispatch_get_main_queue(), ^{ // <--- this line
        
        [self beginCommit];
        
        // Bind to the texture in OpenGL
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, self.textureId);
// ...
        [self postCommit];
    });
}

Wrong pan direction when rotating device

When I'm rotating the device to portrait (Motion and Touch enabled), the pan doesn't work anymore. One direction is rotated by 90 degrees, the other one is totally weird. Would it make sense to store the initial device orientation and when the user rotates the device convert the pan's translation into the correct axis?

Pixel line artifact during 360 jpeg viewer + VR

Hello there!
Thank you for your fabulous classes!
I've found a little artifact during 360° jpeg viewer + VR (it works well without VR).
The problem is only in the right eye (side).
This is the picture that I see:
img_2127
The jpeg that I use is 4000x2000 pixel and the glitch is at the start/end of the picture.
Do you know how can I fix that?
Thank you very much for your help!

Does it support MobileVLCKit.framework?

Thank you for sharing!Does it support MobileVLCKit.framework? I want to use VLC to decode video streams.If so, what should I do, please advise!Thank you!

运行时后出现内存警告

2016-08-24 11:22:31.628 MD360PlayerDemo[6703:2724679] Received memory warning.

  • (void)viewDidLoad {
    [super viewDidLoad];
    // Create a AVPlayerItem
    AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithURL:[NSURL URLWithString:@"http://d8d913s460fub.cloudfront.net/krpanocloud/video/airpano/video-1920x960a.mp4"]];
    self.player = [[AVPlayer alloc] initWithPlayerItem:playerItem];
    [self.player play];
    AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player];
    [playerLayer setFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.width * 9 / 16)];
    [self.view.layer addSublayer:playerLayer];

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

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

    // optional
    [config displayMode:MDModeDisplayNormal];
    [config interactiveMode:MDModeInteractiveMotionWithTouch];
    [config projectionMode:MDModeProjectionSphere];
    [config pinchEnabled:true];
    [config setDirectorFactory:self];

    self.vrLibrary = [config build];
    }

What's the right way to manipulate MD360Director?

Hello, exploring the MD360 classes I have found the MD360Director to change Eye, Angle, Ratio and another properties.

What's the right way to manipulate these values from my ViewController?

When I instance my videoplayer, how I can pass the initValue to MD360Director object?
I want to change the mAngle on initValue and setEyeX, setLookX on MD360Director create method.

Thanks a lot.

crash on glDrawElements_ES2Exec

0   0x00000001181ed9ba in 0x1181ed9ba ()
1   0x000000011553e828 in glDrawElements_ES2Exec ()
2   0x00000001016d1efc in -[MDAbsObject3D onDraw] at /Users/Asha/xcode/MD360Player4iOS/MDVRLibrary/MDVRLibrary/MDAbsObject3D.m:132
3   0x00000001016cdfa6 in -[MD360Renderer rendererOnDrawFrame:width:height:] at /Users/Asha/xcode/MD360Player4iOS/MDVRLibrary/MDVRLibrary/MD360Renderer.m:115
4   0x00000001016cf077 in -[MDGLKViewController glkView:drawInRect:] at /Users/Asha/xcode/MD360Player4iOS/MDVRLibrary/MDVRLibrary/MDGLKViewController.m:63
5   0x000000010389f91a in -[GLKView _display:] ()

YUV Data Support

Demo use CVPixelBufferRef.How to render YUV originnal frame data?

New IJKPlayer vesion

Hello!

I have a problem with with projection on ios when adding a new version of the ijkplayer from Bilibili, version is 0.7.4.

The video is not played on a sphere, it is played flat on the screen. Could you point me to the part of the code where you set this of is there any part of the ijkplayer that needs to be changed?

Detecting iPhone 6/6+ screen scale

#define IS_OS_8_OR_LATER    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)

+(float) getScrrenScale {
    float contentScale = 1.0f;
    if ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)]) {
        if (IS_OS_8_OR_LATER) {
            contentScale = [[UIScreen mainScreen] nativeScale];
        } else {
            contentScale = [[UIScreen mainScreen] scale];
        }
    }
    return contentScale;
}

能夠使用 AvplayerItem 播放VR嗎?

請問
能夠使用 AvplayerItem + AVPlayer 播放VR嗎?

目前使用本地相機拍 直版的影片, (EX: 1080 x 1920)

透過 AvplayerItem + - (void) asVideo:(AVPlayerItem*)playerItem 建立library
播放時發現 直版影片會被轉成橫版的, (1920 x 1080)

請問這問題, 能夠怎麼處理?

The media data could not be decoded on this device

Hi!

I have this error only on iPhone 5 and I have no idea for the reason:

Video player Status Failed: player item error = Error Domain=AVFoundationErrorDomain Code=-11855 "Cannot Decode" UserInfo={NSLocalizedDescription=Cannot Decode, NSUnderlyingError=0x17e9cdd0 {Error Domain=NSOSStatusErrorDomain Code=-12910 "(null)"}, NSLocalizedFailureReason=The media data could not be decoded on this device.}
2016-06-16 09:56:01.762 Videos360[236:8930] Video player Status Failed: player error = (null)

This occurs only on iPhone 5 and only with network videos. Anyone had this problem later? Thanks!!

NSCocoaErrorDomain Code=258

Hi!

I'm using Swift in my project. And I get the following error using this code:
2016-04-20 16:30:36.190 Eagle[11928:637852] ERROR while loading from file: Error Domain=NSCocoaErrorDomain Code=258 "The file name is invalid." 2016-04-20 16:30:36.191 Eagle[11928:637852] ERROR while loading from file: Error Domain=NSCocoaErrorDomain Code=258 "The file name is invalid."

` let playerItem = AVPlayerItem(URL: "http://d8d913s460fub.cloudfront.net/krpanocloud/video/airpano/video-1920x960a.mp4")
let player = AVPlayer(playerItem: playerItem)

                let playerController = AVPlayerViewController()

                playerController.player = player

                playerController.modalPresentationStyle = UIModalPresentationStyle.OverFullScreen
                self.presentViewController(playerController, animated: true, completion: nil)

                player.play()

                let config:MDVRConfiguration = MDVRLibrary.createConfig()

                config.displayMode(MDModeDisplay.Glass)
              //  config.interactiveMode(MDMo)

                config.asVideo(playerItem)
                config.setContainer(self, view: self.view)

                let lib = config.build()`

If I uncomment all the code of your framework, it works.
The program stops working at GLUtil.m at line 254

You know anything I could do?

3D 180度全景播放,修改了纹理坐标后,显示界面异常,该如何修改呢?

你好,我使用了你的sdk来做一个播放器app,播放3D180度的视频,视频源为左右显示的源,我修改了generateSphere中生成的texcoords 部分代码,分屏显示可以看出有3D的效果,但是视频对接的地方会多出一部分异常显示的纹理,一下为我修改的代码,能帮忙看看是那边改错了吗 还是修改思路不正确,谢谢!
//texcoords[t] = s_S;
float curTexcoord = s_S;
switch (type) {
case Type3D180:
if (bLeft) {
texcoords[t] = s< sectors/2?curTexcoord:(s-sectors/2)_S;
}
else{
texcoords[t] = s< sectors/2?(s + sectors/2)_S:curTexcoord;
}

                break;

Visual artifacts on top and bottom of view

Hi !

The player works very nicely and i'm grateful for that.
Only issue is that there are visual artifacts on top and bottom of the sphere views, where the equirectangular image wraps upon itself.
There's some kind of strange banding going on (i'm not talking about the warping which is to be expected). It's more visible when you have a moving video.

Might help, I first saw it using this video : https://www.youtube.com/watch?v=TiCL93jVLyo

Here are some screenshots :
img_0132
img_0133
img_0134

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.