Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 140 lines (128 sloc) 5.221 kB
d99be79 @tomcool420 fixing Examples, creating more examples and putting them in easy to a…
authored
1 //
2 // SMFMoviePreviewDelegateAndDatasourceExample.m
3 // SMFramework
4 //
5 // Created by Thomas Cool on 7/13/11.
6 // Copyright 2011 tomcool.org. All rights reserved.
7 //
8 #import "SMFMoviePreviewController.h"
9 #import "SMFMoviePreviewDelegateAndDatasourceExample.h"
10
11 @implementation SMFMoviePreviewDelegateAndDatasourceExample
12 #pragma mark datasource methods
13 -(NSString *)title
14 {
15 return @"Awesomeness";
16 }
17 -(NSString *)subtitle
18 {
19 return @"An AwkwardTV Production";
20 }
21 -(NSString *)summary
22 {
23 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";
24 }
25 -(NSArray *)headers
26 {
27 return [NSArray arrayWithObjects:@"Details",@"Actors",@"Director",@"Producers",nil];
28 }
29 -(NSArray *)columns
30 {
31 NSArray *actors = [NSArray arrayWithObjects:@"|bile|",@"davilla",@"erica",@"mringwal",@"tomcool",nil];
32 NSArray *directors = [NSArray arrayWithObjects:@"macTijn",@" ",
33 [[[NSAttributedString alloc]initWithString:@"Art Director"
34 attributes:[[BRThemeInfo sharedTheme]metadataSummaryFieldAttributes]]autorelease],
35 @"Leddy",nil];
36 NSArray *producers = [NSArray arrayWithObjects:@"Alan Quatermain",@"gbooker",@"DHowett",nil];
37 BRImage *i = [[BRThemeInfo sharedTheme] hdBadge];
38 NSArray *details = [NSArray arrayWithObjects:
39 @"Action & Comedy",
40 @"Released: 2010",
41 [NSArray arrayWithObjects:
42 i,
43 [[[NSAttributedString alloc] initWithString:@" 2" attributes:[[BRThemeInfo sharedTheme]metadataTitleAttributes]]autorelease],
44 i,nil],
45 @"Run Time: Years",
46 [[SMFThemeInfo sharedTheme]fourPointFiveStars],
47 nil];
48 NSArray *objects = [NSArray arrayWithObjects:details,actors,directors,producers,nil];
49 return objects;
50 }
51 -(NSString *)rating
52 {
53 return @"R";
54 }
55 -(BRImage *)coverArt
56 {
57 return [BRImage imageWithPath:[self posterPath]];
58 }
59 -(NSString *)posterPath
60 {
61 return [[NSBundle bundleForClass:[self class]]pathForResource:@"poster" ofType:@"jpg"];
62 }
63 -(BRPhotoDataStoreProvider *)providerForShelf
64 {
65 NSSet *_set = [NSSet setWithObject:[BRMediaType photo]];
66 NSPredicate *_pred = [NSPredicate predicateWithFormat:@"mediaType == %@",[BRMediaType photo]];
67 BRDataStore *store = [[BRDataStore alloc] initWithEntityName:@"Hello" predicate:_pred mediaTypes:_set];
68 NSArray *assets = [SMFPhotoMethods mediaAssetsForPath:[[NSBundle bundleForClass:[self class]]pathForResource:@"Posters" ofType:@""]];
69 for (id a in assets) {
70 [store addObject:a];
71 }
72
73 //id dSPfCClass = NSClassFromString(@"BRPhotoDataStoreProvider");
74
75 id tcControlFactory = [BRPosterControlFactory factory];
76 id provider = [BRPhotoDataStoreProvider providerWithDataStore:store controlFactory:tcControlFactory];
77 [store release];
78 return provider;
79 }
80 -(NSArray *)buttons
81 {
82 NSMutableArray *buttons = [[NSMutableArray alloc]init];
83 BRButtonControl* b = [BRButtonControl actionButtonWithImage:[[BRThemeInfo sharedTheme]previewActionImage]
84 subtitle:@"Preview"
85 badge:nil];
86 [buttons addObject:b];
87
88 b = [BRButtonControl actionButtonWithImage:[[BRThemeInfo sharedTheme]playActionImage]
89 subtitle:@"Play"
90 badge:nil];
91
92 [buttons addObject:b];
93
94 b = [BRButtonControl actionButtonWithImage:[[BRThemeInfo sharedTheme]queueActionImage]
95 subtitle:@"Queue"
96 badge:nil];
97
98 [buttons addObject:b];
99
100 b = [BRButtonControl actionButtonWithImage:[[BRThemeInfo sharedTheme]rateActionImage]
101 subtitle:@"More"
102 badge:nil];
103 [buttons addObject:b];
104 return [buttons autorelease];
105
106 }
107 #pragma mark delegate methods (examples)
108 -(void)controller:(SMFMoviePreviewController *)c selectedControl:(BRControl *)ctrl {
109 NSLog(@"controller of type %@ selected", [ctrl class]);
110 }
111 //optional
112 -(void)controller:(SMFMoviePreviewController *)c buttonSelectedAtIndex:(int)index {
113 NSLog(@"button at index %d selected", index);
114 }
115 -(void)controller:(SMFMoviePreviewController *)c switchedFocusTo:(BRControl *)newControl {
116 NSLog(@"controller of type %@ focused", [newControl class]);
117 }
118 -(void)controller:(SMFMoviePreviewController *)c shelfLastIndex:(long)index {
119 NSLog(@"last index of shelf was %d", index);
120 }
121 -(void)controllerSwitchToNext:(SMFMoviePreviewController *)c {
122 //flash arrow on, then off
123 [c switchNextArrowOn];
124 [c performSelector:@selector(switchNextArrowOff) withObject:nil afterDelay:0.7f];
125 }
126 -(void)controllerSwitchToPrevious:(SMFMoviePreviewController *)c {
127 //flash arrow on, then off
128 [c switchPreviousArrowOn];
129 [c performSelector:@selector(switchPreviousArrowOff) withObject:nil afterDelay:0.7f];
130 }
131 -(BOOL)controllerCanSwitchToNext:(SMFMoviePreviewController *)c {
132 return YES;
133 }
134 -(BOOL)controllerCanSwitchToPrevious:(SMFMoviePreviewController *)c {
135 return YES;
136 }
137
138
139 @end
Something went wrong with that request. Please try again.