Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
VLC Browser Plugins
Commits
8e49d09e
Commit
8e49d09e
authored
Jan 02, 2013
by
Felix Paul Kühne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Windowed Mac Plugin: fully implement the toolbar
parent
12396c6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
17 deletions
+25
-17
npapi/vlcplugin_mac.mm
npapi/vlcplugin_mac.mm
+25
-17
No files found.
npapi/vlcplugin_mac.mm
View file @
8e49d09e
...
...
@@ -49,8 +49,16 @@
BOOL
_wasPlayingBeforeMouseDown
;
BOOL
_isScrubbing
;
CGFloat
_mouseDownXDelta
;
double
_position
;
BOOL
_isPlaying
;
VlcPluginMac
*
_cppPlugin
;
}
-
(
BOOL
)
_isPlaying
;
@property
(
readwrite
)
double
mediaPosition
;
@property
(
readwrite
)
BOOL
isPlaying
;
@property
(
readwrite
)
VlcPluginMac
*
cppPlugin
;
-
(
void
)
handleMouseDown
:(
CGPoint
)
point
;
-
(
void
)
handleMouseUp
:(
CGPoint
)
point
;
-
(
void
)
handleMouseDragged
:(
CGPoint
)
point
;
...
...
@@ -114,6 +122,9 @@ bool VlcPluginMac::get_toolbar_visible()
void
VlcPluginMac
::
update_controls
()
{
[
controllerLayer
setMediaPosition
:
libvlc_media_player_get_position
(
getMD
())];
[
controllerLayer
setIsPlaying
:
playlist_isplaying
()];
[
controllerLayer
setNeedsDisplay
];
}
...
...
@@ -142,6 +153,7 @@ NPError VlcPluginMac::get_root_layer(void *value)
controllerLayer
=
[[
VLCControllerLayer
alloc
]
init
];
controllerLayer
.
opaque
=
1.
;
[
rootLayer
addSublayer
:
controllerLayer
];
[
controllerLayer
setCppPlugin
:
this
];
*
(
CALayer
**
)
value
=
rootLayer
;
return
NPERR_NO_ERROR
;
...
...
@@ -316,6 +328,10 @@ bool VlcPluginMac::handle_event(void *event)
@implementation
VLCControllerLayer
@synthesize
mediaPosition
=
_position
;
@synthesize
isPlaying
=
_isPlaying
;
@synthesize
cppPlugin
=
_cppPlugin
;
static
CGImageRef
createImageNamed
(
NSString
*
name
)
{
CFURLRef
url
=
CFBundleCopyResourceURL
(
CFBundleGetBundleWithIdentifier
(
CFSTR
(
"com.netscape.vlc"
)),
(
CFStringRef
)
name
,
CFSTR
(
"png"
),
NULL
);
...
...
@@ -366,10 +382,6 @@ static CGImageRef createImageNamed(NSString *name)
[
super
dealloc
];
}
-
(
BOOL
)
_isPlaying
{
return
YES
;
}
#pragma mark -
#pragma mark drawing
...
...
@@ -391,11 +403,7 @@ static CGImageRef createImageNamed(NSString *name)
{
CGRect
sliderRect
=
[
self
_sliderRect
];
CGFloat
fraction
=
0.0
;
/* if (_movie)
fraction = [self _currentTime] / [self _duration];*/
CGFloat
x
=
fraction
*
(
CGRectGetWidth
(
sliderRect
)
-
CGImageGetWidth
(
_knob
));
CGFloat
x
=
self
.
mediaPosition
*
(
CGRectGetWidth
(
sliderRect
)
-
CGImageGetWidth
(
_knob
));
return
CGRectMake
(
CGRectGetMinX
(
sliderRect
)
+
x
,
CGRectGetMinY
(
sliderRect
)
+
1
,
CGImageGetWidth
(
_knob
),
CGImageGetHeight
(
_knob
));
...
...
@@ -408,7 +416,7 @@ static CGImageRef createImageNamed(NSString *name)
-
(
void
)
_drawPlayPauseButtonInContext
:(
CGContextRef
)
context
{
CGContextDrawImage
(
context
,
[
self
_playPauseButtonRect
],
_playImage
);
//playlist_isp
laying
()
? _pauseImage;
CGContextDrawImage
(
context
,
[
self
_playPauseButtonRect
],
self
.
isP
laying
?
_pauseImage
:
_playImage
)
;
}
-
(
void
)
_drawSliderInContext
:(
CGContextRef
)
context
...
...
@@ -453,13 +461,13 @@ static CGImageRef createImageNamed(NSString *name)
{
CGRect
innerRect
=
[
self
_innerSliderRect
];
CGFloat
fraction
=
(
centerX
-
CGRectGetMinX
(
innerRect
))
/
CGRectGetWidth
(
innerRect
);
double
fraction
=
(
centerX
-
CGRectGetMinX
(
innerRect
))
/
CGRectGetWidth
(
innerRect
);
if
(
fraction
>
1.0
)
fraction
=
1.0
;
else
if
(
fraction
<
0.0
)
fraction
=
0.0
;
printf
(
"du
ration
needed
\n
"
);
libvlc_media_player_set_position
(
self
.
cppPlugin
->
getMD
(),
f
ra
c
tion
);
[
self
setNeedsDisplay
];
}
...
...
@@ -467,10 +475,10 @@ static CGImageRef createImageNamed(NSString *name)
-
(
void
)
handleMouseDown
:(
CGPoint
)
point
{
if
(
CGRectContainsPoint
([
self
_sliderRect
],
point
))
{
_wasPlayingBeforeMouseDown
=
[
self
_
isPlaying
]
;
_wasPlayingBeforeMouseDown
=
self
.
isPlaying
;
_isScrubbing
=
YES
;
printf
(
"should
pause
\n
"
);
self
.
cppPlugin
->
playlist_
pause
(
);
if
(
CGRectContainsPoint
([
self
_sliderThumbRect
],
point
))
_mouseDownXDelta
=
point
.
x
-
CGRectGetMidX
([
self
_sliderThumbRect
]);
...
...
@@ -488,12 +496,12 @@ static CGImageRef createImageNamed(NSString *name)
_mouseDownXDelta
=
0
;
if
(
_wasPlayingBeforeMouseDown
)
printf
(
"start to
play
\n
"
);
self
.
cppPlugin
->
playlist_
play
(
);
return
;
}
if
(
CGRectContainsPoint
([
self
_playPauseButtonRect
],
point
))
{
printf
(
"toggle play/p
ause
\n
"
);
self
.
cppPlugin
->
playlist_toggleP
ause
(
);
return
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment