Nextrek
@ 62
Nextrek / iOS / PocketVision / PocketVision / VC / iPhone / LandVC_iPhone.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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
// // LandVC.m // PocketVision // // Created by Fabrizio on 29/01/13. // Copyright (c) 2013 Odyssey. All rights reserved. // #import "LandVC_iPhone.h" #import "TargetConfig.h" #import "NetService.h" #import "DataManager.h" #import "AboutVC.h" #import <AVFoundation/AVFoundation.h> @interface LandVC_iPhone () @end @implementation LandVC_iPhone @synthesize playerContainer; @synthesize bkgImgView; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { } return self; } -(NSUInteger)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskLandscape; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); } - (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(goTimelineStatus) name:@"MsgGoTimelineStatus" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(goAllMinimizedStatus) name:@"MsgGoAllMinimizedStatus" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doPlayChannel:) name:@"PlayChannel" object:nil]; viewsVisible = YES; singleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)]; singleTapGesture.numberOfTapsRequired = 1; [singleTapGesture setCancelsTouchesInView:YES]; [singleTapGesture setDelegate:self]; [self.tapOnVideoFakeView addGestureRecognizer:singleTapGesture]; } - (void) viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; if([DATAMANAGER testConnection]) { [ActivityViewVC showActivityWithSuperView:self.view]; [[NetService getInstance] getChannelList:self]; } else { [self showNoConnError]; } } - (void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; if([DATAMANAGER testConnection]) { DATAMANAGER.purchased = NO; [DATAMANAGER handleADV:self.view callerVC:self]; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)viewDidUnload { [self setTapOnVideoFakeView:nil]; [super viewDidUnload]; } #pragma mark - HANDLE NETWORK REQUESTS - (void)getChannelListRequestDone:(ASIHTTPRequest *)request { // LOG_INFO_X(@"REQUEST PERFORMED - RESPONSE STRING: %@", [request responseString]); // LOG_INFO_X(@"REQUEST PERFORMED - RESPONSE STATUS CODE: %d", [request responseStatusCode]); [ActivityViewVC hideActivityView]; [[DataManager getInstance] parseChannelListResponse:[request responseData]]; if([DATAMANAGER.allChannels count] != 0) { [self completeAppStartup]; [self hideSplashAndShowUI]; [DATAMANAGER loadChannelOnAir]; Channel *channel = [DATAMANAGER.allChannels objectAtIndex:DATAMANAGER.channelOnAirIndex]; [[NSNotificationCenter defaultCenter] postNotificationName:@"PlayChannel" object:channel]; } else { [self showNoConnError]; } } - (void)getChannelListRequestWentWrong:(ASIHTTPRequest *)request { [ActivityViewVC hideActivityView]; LOG_INFO_X(@"RESPONSE WRONG:%@", [request responseString]); [self showNoConnError]; } #pragma mark - Handle Errors Alerts - (void) showNoConnError { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Errore", @"Errore") message:NSLocalizedString(@"Impossibile recuperare la lista canali.", @"Error message") delegate:self cancelButtonTitle:NSLocalizedString(@"Riprova", @"Riprova") otherButtonTitles:nil]; alert.tag = 999; [alert show]; } -(void) alertView: ( UIAlertView *) alertView clickedButtonAtIndex: ( NSInteger ) buttonIndex { if(alertView.tag == 999){ if([DATAMANAGER testConnection]) { [ActivityViewVC showActivityWithSuperView:self.view]; [[NetService getInstance] getChannelList:self]; } else { [self showNoConnError]; } } } #pragma mark - General Setup - (void) completeAppStartup { CGRect f; if (!channelsVC) { channelsVC = [[ChannelsVC alloc] initWithNibName:@"ChannelsVC" bundle:[NSBundle mainBundle]]; if (channelsVC) { f = [channelsVC.view frame]; f.origin = EAST_MINIMIZED_POINT; [channelsVC.view setFrame:f]; [self makeAllViewsVisible:NO]; [self.view addSubview:channelsVC.view]; } } } - (void) hideSplashAndShowUI { [self makeAllViewsVisible:YES]; } - (void)handleSingleTap:(UITapGestureRecognizer *)sender { if (sender == singleTapGesture) { [self tapOnVideo]; } } - (void) tapOnVideo { if (viewsVisible) { if (appStatus == StatusAllMinimized) { [self makeAllViewsVisible:NO]; } else [self goAllMinimizedStatus]; } else { [self makeAllViewsVisible:YES]; } } - (void) playLive:(NSString*)url { movieController = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:url]]; [movieController.view setFrame:CGRectMake(0, 0, playerContainer.frame.size.width, playerContainer.frame.size.height)]; [[movieController view]setAutoresizingMask: UIViewAutoresizingFlexibleWidth]; [playerContainer addSubview: movieController.view]; [movieController setControlStyle:MPMovieControlStyleEmbedded]; [movieController stop]; [movieController play]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinishedCallBack:) name:MPMoviePlayerPlaybackDidFinishNotification object:movieController]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doneButtonClick:) name:MPMoviePlayerWillExitFullscreenNotification object:nil]; } - (void) playbackFinishedCallBack:(NSNotification *)notification { [[NSNotificationCenter defaultCenter] removeObserver:self name: MPMoviePlayerPlaybackDidFinishNotification object:[notification object]]; } -(void)doneButtonClick:(NSNotification*)aNotification { [movieController play]; } #pragma mark - Channel Play Handle - (void) doPlayChannel:(NSNotification *)notification { Channel *channel = [notification object]; [DATAMANAGER saveChannelOnAir:[DATAMANAGER.allChannels indexOfObject:channel]]; LOG_INFO_X(@"INDEX SAVED: %d",[DATAMANAGER.allChannels indexOfObject:channel]); LOG_INFO_X(@"STREAMING URL: %@",channel.streaming_url); [self playLive:channel.streaming_url]; [self makeAllViewsVisible:YES]; } #pragma mark - TRANSITIONS - (void) makeAllViewsVisible:(BOOL)visible { if (visible) { [self.view bringSubviewToFront:aboutButton]; [channelsVC minimize]; appStatus = StatusAllMinimized; } else { [channelsVC hide]; appStatus = StatusAllHidden; } viewsVisible = visible; } - (void) goAllMinimizedStatus { [channelsVC minimize]; appStatus = StatusAllMinimized; [self.view bringSubviewToFront:aboutButton]; } - (void) goTimelineStatus { [self.view sendSubviewToBack:aboutButton]; [channelsVC show]; appStatus = StatusChannelList; } #pragma mark - IBActions - (IBAction)doAbout { AboutVC *aboutVC = [[AboutVC alloc] initWithNibName:nil bundle:nil]; aboutVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:aboutVC animated:YES]; } @end |
Commits for Nextrek/iOS/PocketVision/PocketVision/VC/iPhone/LandVC_iPhone.m
Revision | Author | Commited | Message |
---|---|---|---|
62 | FAquili | Sat 18 Jan, 2014 16:39:26 +0000 | PocketVision 1.0 |