Google VR View - 设置视频类型
Google VR View - Setting type of video
所以我正在尝试使用 Google 的 VR SDK 在我的应用程序中播放视频,但是我遇到了一些问题。尽管有文档,但我们似乎无法再设置视频的类型,所以我得到的视频显示如下:
我根本不能像我应该的那样移动它。此外,全屏模式的参数似乎不起作用。有谁知道如何解决这个问题?这是我使用的代码:
#import <UIKit/UIKit.h>
#import "NewViewController.h"
#import "GVRVideoView.h"
@interface NewViewController ()
@property (nonatomic) IBOutlet GVRVideoView *viewView;
@end
@implementation NewViewController {
BOOL _isPaused;
}
- (instancetype)init {
self = [super initWithNibName:nil bundle:nil];
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
_viewView.enableFullscreenButton = YES;
_viewView.enableCardboardButton = YES;
_isPaused = true;
// Load the sample 360 video, which is of type stereo-over-under.
NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"congo" ofType:@"mp4"];
[_viewView loadFromUrl:[[NSURL alloc] initFileURLWithPath:videoPath]];
}
#pragma mark - GVRVideoViewDelegate
- (void)widgetViewDidTap:(GVRWidgetView *)widgetView {
if (_isPaused) {
[_viewView resume];
} else {
[_viewView pause];
}
_isPaused = !_isPaused;
}
- (void)widgetView:(GVRWidgetView *)widgetView didLoadContent:(id)content {
NSLog(@"Finished loading video");
}
- (void)widgetView:(GVRWidgetView *)widgetView
didFailToLoadContent:(id)content
withErrorMessage:(NSString *)errorMessage {
NSLog(@"Failed to load video: %@", errorMessage);
}
- (void)videoView:(GVRVideoView*)videoView didUpdatePosition:(NSTimeInterval)position {
// Loop the video when it reaches the end.
if (position == videoView.duration) {
[videoView seekTo:0];
[videoView resume];
}
}
@end
没有传递类型的方法 loadFromUrl:
默认为 kGVRVideoTypeMono
。
方法签名应该可以回答您的问题:
/**
* Load a local or remote video from a url and start playing.
*
* The video is assumed to be of type |kGVRVideoTypeMono|.
*/
- (void)loadFromUrl:(NSURL*)videoUrl;
/**
* Load a local or remote video from a url and start playing.
*
* The video type is set by |videoType|.
*/
- (void)loadFromUrl:(NSURL*)videoUrl ofType:(GVRVideoType)videoType;
GVRVideoView have two type :
1) kGVRVideoTypeMono
2) kGVRVideoTypeStereoOverUnder
/** Enum for video image types. */
typedef NS_ENUM(int, GVRVideoType) {
// Each video frame is a monocular equirectangular panorama.
// Each frame image is expected to cover 360 degrees along its horizontal axis.
kGVRVideoTypeMono = 1,
// Each video frame contains two vertically-stacked equirectangular panoramas. The top part of
// the frame contains pixels for the left eye, while the bottom part of the frame contains
// pixels for the right eye.
kGVRVideoTypeStereoOverUnder,
};
If below method used : The video is assumed to be of type |kGVRVideoTypeMono|.
- (void)loadFromUrl:(NSURL*)videoUrl;
If below method used then -The video type is set by |ofType:kGVRVideoTypeMono /kGVRVideoTypeStereoOverUnder|
- (void)loadFromUrl:(NSURL*)videoUrl ofType:(GVRVideoType)videoType;
e.g : [_videoView loadFromUrl:_videoURL ofType:kGVRVideoTypeMono];
即使我也面临同样的问题
所以我改变了
options.inputType = Options.TYPE_STEREO_OVER_UNDER;
到
Options options = new Options();
options.inputType = Options.TYPE_MONO;
所以视频现在工作正常
所以我正在尝试使用 Google 的 VR SDK 在我的应用程序中播放视频,但是我遇到了一些问题。尽管有文档,但我们似乎无法再设置视频的类型,所以我得到的视频显示如下:
我根本不能像我应该的那样移动它。此外,全屏模式的参数似乎不起作用。有谁知道如何解决这个问题?这是我使用的代码:
#import <UIKit/UIKit.h>
#import "NewViewController.h"
#import "GVRVideoView.h"
@interface NewViewController ()
@property (nonatomic) IBOutlet GVRVideoView *viewView;
@end
@implementation NewViewController {
BOOL _isPaused;
}
- (instancetype)init {
self = [super initWithNibName:nil bundle:nil];
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
_viewView.enableFullscreenButton = YES;
_viewView.enableCardboardButton = YES;
_isPaused = true;
// Load the sample 360 video, which is of type stereo-over-under.
NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"congo" ofType:@"mp4"];
[_viewView loadFromUrl:[[NSURL alloc] initFileURLWithPath:videoPath]];
}
#pragma mark - GVRVideoViewDelegate
- (void)widgetViewDidTap:(GVRWidgetView *)widgetView {
if (_isPaused) {
[_viewView resume];
} else {
[_viewView pause];
}
_isPaused = !_isPaused;
}
- (void)widgetView:(GVRWidgetView *)widgetView didLoadContent:(id)content {
NSLog(@"Finished loading video");
}
- (void)widgetView:(GVRWidgetView *)widgetView
didFailToLoadContent:(id)content
withErrorMessage:(NSString *)errorMessage {
NSLog(@"Failed to load video: %@", errorMessage);
}
- (void)videoView:(GVRVideoView*)videoView didUpdatePosition:(NSTimeInterval)position {
// Loop the video when it reaches the end.
if (position == videoView.duration) {
[videoView seekTo:0];
[videoView resume];
}
}
@end
没有传递类型的方法 loadFromUrl:
默认为 kGVRVideoTypeMono
。
方法签名应该可以回答您的问题:
/**
* Load a local or remote video from a url and start playing.
*
* The video is assumed to be of type |kGVRVideoTypeMono|.
*/
- (void)loadFromUrl:(NSURL*)videoUrl;
/**
* Load a local or remote video from a url and start playing.
*
* The video type is set by |videoType|.
*/
- (void)loadFromUrl:(NSURL*)videoUrl ofType:(GVRVideoType)videoType;
GVRVideoView have two type :
1) kGVRVideoTypeMono
2) kGVRVideoTypeStereoOverUnder
/** Enum for video image types. */
typedef NS_ENUM(int, GVRVideoType) {
// Each video frame is a monocular equirectangular panorama.
// Each frame image is expected to cover 360 degrees along its horizontal axis.
kGVRVideoTypeMono = 1,
// Each video frame contains two vertically-stacked equirectangular panoramas. The top part of
// the frame contains pixels for the left eye, while the bottom part of the frame contains
// pixels for the right eye.
kGVRVideoTypeStereoOverUnder,
};
If below method used : The video is assumed to be of type |kGVRVideoTypeMono|.
- (void)loadFromUrl:(NSURL*)videoUrl;
If below method used then -The video type is set by |ofType:kGVRVideoTypeMono /kGVRVideoTypeStereoOverUnder|
- (void)loadFromUrl:(NSURL*)videoUrl ofType:(GVRVideoType)videoType;
e.g : [_videoView loadFromUrl:_videoURL ofType:kGVRVideoTypeMono];
即使我也面临同样的问题 所以我改变了
options.inputType = Options.TYPE_STEREO_OVER_UNDER;
到
Options options = new Options();
options.inputType = Options.TYPE_MONO;
所以视频现在工作正常