]> git.sesse.net Git - vlc/blob - projects/macosx/frontrow_plugin/VLCPlayerController.m
macosx/frontrow_plugin: VLCMediaListController, display a mediaListAspect in a FrontR...
[vlc] / projects / macosx / frontrow_plugin / VLCPlayerController.m
1 //
2 //  VLCPlayerController.m
3 //  FRVLC
4 //
5 //  Created by hyei on 06/09/07.
6 //  Copyright 2007 __MyCompanyName__. All rights reserved.
7 //
8
9 #import "VLCPlayerController.h"
10
11 #import <BackRow/BREvent.h>
12 #import <BackRow/BRLayer.h>
13 #import <BackRow/BRControllerStack.h>
14
15 @implementation VLCPlayerController
16
17 - init
18 {
19     self = [super init];
20     
21     BRLayer * layer = [self layer];
22     _mediaLayer = [VLCMediaLayer layer];
23     _mediaLayer.frame = layer.bounds;
24     _mediaLayer.autoresizingMask = kCALayerWidthSizable|kCALayerHeightSizable;
25     
26     [layer addSublayer:_mediaLayer];
27     
28     return self;
29 }
30
31 - (VLCMedia *)media
32 {
33     return [_mediaLayer media];
34 }
35
36 - (void)setMedia:(VLCMedia *)media
37 {
38     _mediaLayer.media = media;
39 }
40
41 - (void)brEventAction:(BREvent*)event
42 {
43     BREventUsage usage = [event usage];
44     BREventValue value = [event value];
45     VLCMediaPlayer * player = [_mediaLayer player];
46     
47     NSLog(@"usage: %d value: %d", usage, value);
48     
49     switch(usage) {
50         case BREventOKUsage:
51             [_mediaLayer playPause];
52             break;
53         case BREventRightUsage:
54         {
55             NSLog(@"RIGHT");
56             float position = [player position];
57             position += 0.05;
58             position = MIN(1.0, MAX(0.0, position));
59             [player setPosition:position];
60             break;
61         }
62         case BREventLeftUsage:
63         {
64             NSLog(@"LEFT");
65             float position = [player position];
66             position -= 0.05;
67             position = MIN(1.0, MAX(0.0, position));
68             [player setPosition:position];
69             break;
70         }
71         case BREventMenuUsage:
72             [[self stack] popController];
73         default:
74             break;
75     }
76 }
77
78 - (BOOL)firstResponder
79 {
80     return YES;
81 }
82
83 - (void)controlWillDeactivate
84 {
85     [_mediaLayer.player pause];
86     [super controlWillDeactivate];
87 }
88
89 - (void)controlWasActivated
90 {
91     [super controlWasActivated];
92     [_mediaLayer.player play];
93 }
94
95 @end