-
Notifications
You must be signed in to change notification settings - Fork 12
/
SMFMoviePreviewDelegateAndDatasourceExample.m
139 lines (128 loc) · 5.1 KB
/
SMFMoviePreviewDelegateAndDatasourceExample.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
139
//
// SMFMoviePreviewDelegateAndDatasourceExample.m
// SMFramework
//
// Created by Thomas Cool on 7/13/11.
// Copyright 2011 tomcool.org. All rights reserved.
//
#import "SMFMoviePreviewController.h"
#import "SMFMoviePreviewDelegateAndDatasourceExample.h"
@implementation SMFMoviePreviewDelegateAndDatasourceExample
#pragma mark datasource methods
-(NSString *)title
{
return @"Awesomeness";
}
-(NSString *)subtitle
{
return @"An AwkwardTV Production";
}
-(NSString *)summary
{
return @"Awesomeness, a history of development on the AppleTV. from tragedy to comedy, from whining to bitching, from compliments to insults: the History of the AppleTV in 5 acts. Complete with exta bashing, QQ and whining";
}
-(NSArray *)headers
{
return [NSArray arrayWithObjects:@"Details",@"Actors",@"Director",@"Producers",nil];
}
-(NSArray *)columns
{
NSArray *actors = [NSArray arrayWithObjects:@"|bile|",@"davilla",@"erica",@"mringwal",@"tomcool",nil];
NSArray *directors = [NSArray arrayWithObjects:@"macTijn",@" ",
[[[NSAttributedString alloc]initWithString:@"Art Director"
attributes:[[BRThemeInfo sharedTheme]metadataSummaryFieldAttributes]]autorelease],
@"Leddy",nil];
NSArray *producers = [NSArray arrayWithObjects:@"Alan Quatermain",@"gbooker",@"DHowett",nil];
BRImage *i = [[BRThemeInfo sharedTheme] hdBadge];
NSArray *details = [NSArray arrayWithObjects:
@"Action & Comedy",
@"Released: 2010",
[NSArray arrayWithObjects:
i,
[[[NSAttributedString alloc] initWithString:@" 2" attributes:[[BRThemeInfo sharedTheme]metadataTitleAttributes]]autorelease],
i,nil],
@"Run Time: Years",
[[SMFThemeInfo sharedTheme]fourPointFiveStars],
nil];
NSArray *objects = [NSArray arrayWithObjects:details,actors,directors,producers,nil];
return objects;
}
-(NSString *)rating
{
return @"R";
}
-(BRImage *)coverArt
{
return [BRImage imageWithPath:[self posterPath]];
}
-(NSString *)posterPath
{
return [[NSBundle bundleForClass:[self class]]pathForResource:@"poster" ofType:@"jpg"];
}
-(BRPhotoDataStoreProvider *)providerForShelf
{
NSSet *_set = [NSSet setWithObject:[BRMediaType photo]];
NSPredicate *_pred = [NSPredicate predicateWithFormat:@"mediaType == %@",[BRMediaType photo]];
BRDataStore *store = [[BRDataStore alloc] initWithEntityName:@"Hello" predicate:_pred mediaTypes:_set];
NSArray *assets = [SMFPhotoMethods mediaAssetsForPath:[[NSBundle bundleForClass:[self class]]pathForResource:@"Posters" ofType:@""]];
for (id a in assets) {
[store addObject:a];
}
//id dSPfCClass = NSClassFromString(@"BRPhotoDataStoreProvider");
id tcControlFactory = [BRPosterControlFactory factory];
id provider = [BRPhotoDataStoreProvider providerWithDataStore:store controlFactory:tcControlFactory];
[store release];
return provider;
}
-(NSArray *)buttons
{
NSMutableArray *buttons = [[NSMutableArray alloc]init];
BRButtonControl* b = [BRButtonControl actionButtonWithImage:[[BRThemeInfo sharedTheme]previewActionImage]
subtitle:@"Preview"
badge:nil];
[buttons addObject:b];
b = [BRButtonControl actionButtonWithImage:[[BRThemeInfo sharedTheme]playActionImage]
subtitle:@"Play"
badge:nil];
[buttons addObject:b];
b = [BRButtonControl actionButtonWithImage:[[BRThemeInfo sharedTheme]queueActionImage]
subtitle:@"Queue"
badge:nil];
[buttons addObject:b];
b = [BRButtonControl actionButtonWithImage:[[BRThemeInfo sharedTheme]rateActionImage]
subtitle:@"More"
badge:nil];
[buttons addObject:b];
return [buttons autorelease];
}
#pragma mark delegate methods (examples)
-(void)controller:(SMFMoviePreviewController *)c selectedControl:(BRControl *)ctrl {
NSLog(@"controller of type %@ selected", [ctrl class]);
}
//optional
-(void)controller:(SMFMoviePreviewController *)c buttonSelectedAtIndex:(int)index {
NSLog(@"button at index %d selected", index);
}
-(void)controller:(SMFMoviePreviewController *)c switchedFocusTo:(BRControl *)newControl {
NSLog(@"controller of type %@ focused", [newControl class]);
}
-(void)controller:(SMFMoviePreviewController *)c shelfLastIndex:(long)index {
NSLog(@"last index of shelf was %d", index);
}
-(void)controllerSwitchToNext:(SMFMoviePreviewController *)c {
//flash arrow on, then off
[c switchNextArrowOn];
[c performSelector:@selector(switchNextArrowOff) withObject:nil afterDelay:0.7f];
}
-(void)controllerSwitchToPrevious:(SMFMoviePreviewController *)c {
//flash arrow on, then off
[c switchPreviousArrowOn];
[c performSelector:@selector(switchPreviousArrowOff) withObject:nil afterDelay:0.7f];
}
-(BOOL)controllerCanSwitchToNext:(SMFMoviePreviewController *)c {
return YES;
}
-(BOOL)controllerCanSwitchToPrevious:(SMFMoviePreviewController *)c {
return YES;
}
@end