我正在尝试为MacOSX10.10开发一个Cocoa应用程序,它在VLCKit中实现了一些视频流。现在:

这是我的密码:
viewController.h
#import <Cocoa/Cocoa.h>
#import <VLCKit/VLCKit.h>
@interface ViewController : NSViewController<VLCMediaPlayerDelegate>
@property (weak) IBOutlet VLCVideoView *_vlcVideoView;
//delegates
- (void)mediaPlayerTimeChanged:(NSNotification *)aNotification;
@endviewController.m
#import "ViewController.h"
@implementation ViewController
{
VLCMediaPlayer *player;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[player setDelegate:self];
[self._vlcVideoView setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
self._vlcVideoView.fillScreen = YES;
player = [[VLCMediaPlayer alloc] initWithVideoView:self._vlcVideoView];
NSURL *url = [NSURL URLWithString:@"http://MyRemoteUrl.com/video.mp4"];
VLCMedia *movie = [VLCMedia mediaWithURL:url];
[player setMedia:movie];
[player play];
}
- (void)mediaPlayerTimeChanged:(NSNotification *)aNotification
{
//Here I want to retrieve the current video position.
}
@end视频启动和播放正确。但是我不能让代表去工作。我哪里错了?
以下是我的问题:
谢谢您的任何答复!
发布于 2014-11-06 10:41:47
我成功了!
下面是代码:
- (void)viewDidLoad
{
[super viewDidLoad];
[player setDelegate:self];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mediaPlayerTimeChanged:) name:VLCMediaPlayerTimeChanged object:nil];
}代码:
- (void)mediaPlayerTimeChanged:(NSNotification *)aNotification
{
VLCMediaPlayer *player = [aNotification object];
VLCTime *currentTime = player.time;
}https://stackoverflow.com/questions/26769546
复制相似问题