[vlc-commits] mac plugin: add hack to support Safari 5 which is the latest version still running on OS X 10.6
Felix Paul Kühne
git at videolan.org
Mon Feb 10 14:57:02 CET 2014
npapi-vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Mon Feb 10 14:56:46 2014 +0100| [ec00814f4aca50ffd2037b010e800fe7e8d0eb5a] | committer: Felix Paul Kühne
mac plugin: add hack to support Safari 5 which is the latest version still running on OS X 10.6
> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=ec00814f4aca50ffd2037b010e800fe7e8d0eb5a
---
npapi/vlcplugin_mac.mm | 49 +++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 44 insertions(+), 5 deletions(-)
diff --git a/npapi/vlcplugin_mac.mm b/npapi/vlcplugin_mac.mm
index b5b472b..e89067f 100644
--- a/npapi/vlcplugin_mac.mm
+++ b/npapi/vlcplugin_mac.mm
@@ -43,6 +43,14 @@
@end
@interface VLCBrowserRootLayer : CALayer
+{
+ NSTimer *_interfaceUpdateTimer;
+ VlcPluginMac *_cppPlugin;
+}
+ at property (readwrite) VlcPluginMac * cppPlugin;
+
+- (void)startUIUpdateTimer;
+
- (void)addVoutLayer:(CALayer *)aLayer;
- (void)removeVoutLayer:(CALayer *)aLayer;
- (CGSize)currentOutputSize;
@@ -123,6 +131,13 @@ VlcPluginMac::VlcPluginMac(NPP instance, NPuint16_t mode) :
VlcPluginBase(instance, mode)
{
browserRootLayer = [[VLCBrowserRootLayer alloc] init];
+ [browserRootLayer setCppPlugin:this];
+
+ const char *userAgent = NPN_UserAgent(this->getBrowser());
+ if (strstr(userAgent, "Safari") && strstr(userAgent, "Version/5")) {
+ NSLog(@"Safari 5 detected, deploying UI update timer");
+ [browserRootLayer performSelector:@selector(startUIUpdateTimer) withObject:nil afterDelay:1.];
+ }
}
VlcPluginMac::~VlcPluginMac()
@@ -212,10 +227,6 @@ bool VlcPluginMac::get_toolbar_visible()
void VlcPluginMac::update_controls()
{
- [controllerLayer setMediaPosition: libvlc_media_player_get_position(getMD())];
- [controllerLayer setIsPlaying: playlist_isplaying()];
- [controllerLayer setIsFullscreen:this->get_fullscreen()];
-
libvlc_state_t currentstate = libvlc_media_player_get_state(getMD());
if (currentstate == libvlc_Playing || currentstate == libvlc_Paused || currentstate == libvlc_Opening) {
[noMediaLayer setHidden: YES];
@@ -226,7 +237,12 @@ void VlcPluginMac::update_controls()
[playbackLayer setHidden: YES];
}
- [controllerLayer setNeedsDisplay];
+ if (controllerLayer) {
+ [controllerLayer setMediaPosition: libvlc_media_player_get_position(getMD())];
+ [controllerLayer setIsPlaying: playlist_isplaying()];
+ [controllerLayer setIsFullscreen:this->get_fullscreen()];
+ [controllerLayer setNeedsDisplay];
+ }
}
bool VlcPluginMac::create_windows()
@@ -382,6 +398,29 @@ bool VlcPluginMac::handle_event(void *event)
return self;
}
+- (void)startUIUpdateTimer
+{
+ _interfaceUpdateTimer = [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(_updateUI) userInfo:nil repeats:YES];
+ [_interfaceUpdateTimer retain];
+ [_interfaceUpdateTimer fire];
+}
+
+- (void)dealloc
+{
+ if (_interfaceUpdateTimer) {
+ [_interfaceUpdateTimer invalidate];
+ [_interfaceUpdateTimer release];
+ }
+
+ [super dealloc];
+}
+
+- (void)_updateUI
+{
+ if (_cppPlugin)
+ _cppPlugin->update_controls();
+}
+
- (void)addVoutLayer:(CALayer *)aLayer
{
[CATransaction begin];
More information about the vlc-commits
mailing list