2016-07-16 4 views
0

Google Cardboard/VRView SDK를 내 프로젝트에 구현했으며 비디오를로드하여 앱이 처음로드 될 때 일시 중지되도록하려고합니다.Obj C - Google Cardboard 비디오가 작동하지 않음

/TRUE으로 변수를 설정했지만보기 컨트롤러가로드 될 때 비디오가 자동으로 재생되고 재생됩니다.

누구나 이전에 사용 했습니까? 당신의 didLoadContent 위임 방법이 추가

#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 
+0

'loadFromUrl :'후,'[viewView pause];'를 시도해보십시오. – Larme

+0

불행히도 작동하지 않습니다. – dwinnbrown

답변

0
- (void)widgetView:(GVRWidgetView *)widgetView didLoadContent:(id)content { 
    NSLog(@"Finished loading video"); 
    [self.videoView pause]; 
    self.isPaused = YES; 
} 

보십시오. 이렇게하면 동영상이로드되면 일시 중지됩니다.

관련 문제