Ich habe das Google Cardboard/VRView SDK in mein Projekt implementiert und versuche das Video zu laden, so dass es angehalten wird, wenn die App geladen wird.Obj C - Google Cardboard Pause Video funktioniert nicht
Obwohl die _isPaused
Variable auf YES
/TRUE
eingestellt ist, scheint es nicht zu funktionieren und das Video wird automatisch abgespielt, wenn der View Controller geladen wird.
Wer hat das schon mal benutzt?
#import <UIKit/UIKit.h>
#import "NewViewController.h"
#import "GCSVideoView.h"
@interface NewViewController()
@property (nonatomic) IBOutlet GCSVideoView *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 = NO;
_isPaused = YES;
// Load the sample 360 video, which is of type stereo-over-under.
NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"video" ofType:@"mp4"];
[_viewView loadFromUrl:[[NSURL alloc] initFileURLWithPath:videoPath]];
}
#pragma mark - GVRVideoViewDelegate
- (void)widgetViewDidTap:(GCSWidgetView *)widgetView {
if (_isPaused) {
[_viewView resume];
} else {
[_viewView pause];
}
_isPaused = !_isPaused;
}
- (void)widgetView:(GCSWidgetView *)widgetView didLoadContent:(id)content {
NSLog(@"Finished loading video");
}
- (void)widgetView:(GCSWidgetView *)widgetView
didFailToLoadContent:(id)content
withErrorMessage:(NSString *)errorMessage {
NSLog(@"Failed to load video: %@", errorMessage);
}
- (void)videoView:(GCSVideoView*)videoView didUpdatePosition:(NSTimeInterval)position {
// Loop the video when it reaches the end.
if (position == videoView.duration) {
[videoView seekTo:0];
[videoView resume];
}
}
@end
Nach 'loadFromUrl:' versuchen Sie '[viewView pause];'? – Larme
Funktioniert leider nicht – dwinnbrown