/
ATVFVideoPlayerController.m
138 lines (111 loc) · 4.39 KB
/
ATVFVideoPlayerController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//
// ATVFVideoPlayerController.m
// ATVFiles
//
// Created by Eric Steil III on 10/21/07.
// Copyright (C) 2007-2008 Eric Steil III
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#import "ATVFVideoPlayerController.h"
#import "config.h"
#import "ATVFVideoPlayerMenu.h"
#import <SapphireCompatClasses/SapphireFrontRowCompat.h>
#import "ATVFVideoPlayer.h"
@interface ATVFVideoPlayerController (FRCompat)
-(void)_removeTransportControl;
-(void)_addTransportControl;
@end
@implementation ATVFVideoPlayerController
// Handle menu keypress, and ignore everything else.
-(BOOL)brEventAction:(BREvent *)event {
//LOG(@"In -brEventAction: (%@)%@", [event class], event);
if([[self stack] peekController] != self)
return NO;
switch([event pageUsageHash]) {
#ifdef PLAYBACK_CONTEXT_MENU
case kBREventTapMenu: // ATV
case BREVENT_HASH(12, 134): // 10.5
; // won't compile without this??!??
ATVFVideoPlayerMenu *menu;
if([self respondsToSelector:@selector(scene)]) // ATV
menu = [[[ATVFVideoPlayerMenu alloc] initWithScene:[self scene] player:[self player] controller:self] autorelease];
else // 10.5
menu = [[[ATVFVideoPlayerMenu alloc] initWithScene:[BRRenderScene sharedInstance] player:[self player] controller:self] autorelease];
[menu addLabel:@"net.ericiii.atvfiles.playback-context-menu"];
if([SapphireFrontRowCompat usingFrontRow])
[self _removeTransportControl];
else
[self _removeTransportLayer];
[(ATVFVideoPlayer *)[self player] pause];
[[self stack] pushController:menu];
return YES;
break;
// context menu
// BRListControl *list = [self list];
// ATVFMediaAsset *asset = [_contents mediaForIndex:[list selection]];
// LOG(@"Context menu button pressed!");
// LOG(@" List: (%@)%@", [list class], list);
// LOG(@" Selected: %d", [list selection]);
//
// LOG(@" Selected asset: (%@)%@ <%@>", [asset class], asset, [asset mediaURL]);
//
// ATVFContextMenu *contextMenu = [[[ATVFContextMenu alloc] initWithScene:[self scene] forAsset:asset] autorelease];
// [contextMenu setListIcon:[self listIcon]];
// [[self stack] pushController:contextMenu];
//
// return YES;
// break;
#endif
}
return [super brEventAction:event];
}
#if 0
-(void)wasExhumedByPoppingController:(id)controller {
[super wasExhumedByPoppingController:controller];
LOG(@"-ATVFVideoPlayerController wasExhumedByPoppingController: (%@)%@", [controller class], controller);
// Resume playback if it's our option dialog
if([controller isLabelled:@"net.ericiii.atvfiles.playback-context-menu"]) {
LOG(@"Is playback context menu");
[(BRMediaPlayer *)[self player] resume];
// [self _removeTransportLayer];
if(![SapphireFrontRowCompat usingFrontRow])
[[controller popAnimation] run];
if([SapphireFrontRowCompat usingFrontRow])
[self _addTransportControl];
else
[self _addTransportLayer];
}
}
-(id)buryAnimationWithPushingController:(BRLayerController *)controller {
id r = nil;
id r2 = nil;
if(![SapphireFrontRowCompat usingFrontRow])
r = [controller pushAnimation];
r2 = [super buryAnimationWithPushingController:controller];
LOG(@"In -buryAnimationWithPushingController, controller says (%@)%@, super says (%@)%@", [r class], r, [r2 class], r2);
return r2;
}
-(void)wasBuriedByPushingController:(BRLayerController *)controller {
[super wasBuriedByPushingController:controller];
if([controller isLabelled:@"net.ericiii.atvfiles.playback-context-menu"]) {
// [[self buryAnimationWithPushingController:controller] run];
if(![SapphireFrontRowCompat usingFrontRow]) {
[[controller pushAnimation] run];
[self _removeMasterLayer];
}
}
}
#endif
@end