3
我正在嘗試爲Mac OSX 10.10開發一個Cocoa應用程序,該應用程序在VLCKit中實現了一些視頻流。 現在:VLCKit:可可應用程序中的VLCMediaPlayerDelegate
- 我已經編譯了.framework庫,我已經在Xcode進口它。
- 我添加了一個自定義視圖我Main.storyboard並將其設置爲一個VLCVideoView
- 在我ViewController.h我已經實施了VLCMediaPlayerDelegate以接收來自玩家的通知
- 我怎樣才能設置代理接收關於當前播放時間的通知?
- 如何閱讀NSNotification? (我並不是真正習慣Obj-C)
她E公司我的代碼:
viewController.h
#import <Cocoa/Cocoa.h>
#import <VLCKit/VLCKit.h>
@interface ViewController : NSViewController<VLCMediaPlayerDelegate>
@property (weak) IBOutlet VLCVideoView *_vlcVideoView;
//delegates
- (void)mediaPlayerTimeChanged:(NSNotification *)aNotification;
@end
viewController.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
視頻啓動和正常播放。但是我無法讓代表工作。 我錯在哪裏?
這裏是我的問題:
預先感謝您的任何答案!
對於我的第一個問題我已經找到了解決方案!我忘了添加下面這行代碼: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mediaPlayerTimeChanged :) name:VLCMediaPlayerTimeChanged object:nil]; – 2014-11-06 00:21:39