1 /*****************************************************************************
2 * VLCPlayerController.m: Front Row plugin
3 *****************************************************************************
4 * Copyright (C) 2007 - 2008 the VideoLAN Team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #import "VLCPlayerController.h"
26 #import <BackRow/BREvent.h>
27 #import <BackRow/BRLayer.h>
28 #import <BackRow/BRControllerStack.h>
30 @implementation VLCPlayerController
36 BRLayer * layer = [self layer];
37 _mediaLayer = [VLCMediaLayer layer];
38 _mediaLayer.frame = layer.bounds;
39 _mediaLayer.autoresizingMask = kCALayerWidthSizable|kCALayerHeightSizable;
41 [layer addSublayer:_mediaLayer];
48 return [_mediaLayer media];
51 - (void)setMedia:(VLCMedia *)media
53 _mediaLayer.media = media;
56 - (void)brEventAction:(BREvent*)event
58 BREventUsage usage = [event usage];
59 BREventValue value = [event value];
60 VLCMediaPlayer * player = [_mediaLayer player];
62 NSLog(@"usage: %d value: %d", usage, value);
66 [_mediaLayer playPause];
68 case BREventRightUsage:
71 float position = [player position];
73 position = MIN(1.0, MAX(0.0, position));
74 [player setPosition:position];
77 case BREventLeftUsage:
80 float position = [player position];
82 position = MIN(1.0, MAX(0.0, position));
83 [player setPosition:position];
89 [[[VLCLibrary sharedLibrary] audio] setVolume:[[[VLCLibrary sharedLibrary] audio] volume]+20];
92 case BREventDownUsage:
95 [[[VLCLibrary sharedLibrary] audio] setVolume:[[[VLCLibrary sharedLibrary] audio] volume]-20];
98 case BREventMenuUsage:
99 [[self stack] popController];
105 - (BOOL)firstResponder
110 - (void)controlWillDeactivate
112 [_mediaLayer.player pause];
113 [super controlWillDeactivate];
116 - (void)controlWasActivated
118 [super controlWasActivated];
119 [_mediaLayer.player play];