/Mobile/iPhone/StoffiRemote/StoffiRemote/RemoteViewController.m

http://yet-another-music-application.googlecode.com/ · Objective C · 91 lines · 58 code · 19 blank · 14 comment · 2 complexity · d4eb94746c43cd55e78b48f5fa30367b MD5 · raw file

  1. //
  2. // RemoteViewController.m
  3. // StoffiRemote
  4. //
  5. // Created by Fredrik Gadnell on 9/26/11.
  6. // Copyright 2011 __MyCompanyName__. All rights reserved.
  7. //
  8. #import "RemoteViewController.h"
  9. #import "LoginViewController.h"
  10. #import "User.h"
  11. @implementation RemoteViewController
  12. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  13. {
  14. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  15. if (self) {
  16. // Custom initialization
  17. }
  18. return self;
  19. }
  20. - (IBAction)logoutPressed {
  21. User *user = [User currentUser];
  22. user = nil;
  23. [self presentLoginScreenAnimated:YES];
  24. }
  25. - (void)presentLoginScreenAnimated:(BOOL)animated {
  26. LoginViewController *lvc = [[LoginViewController alloc] init];
  27. lvc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
  28. [self presentModalViewController:lvc animated:animated];
  29. }
  30. - (void)dealloc
  31. {
  32. [super dealloc];
  33. }
  34. - (void)didReceiveMemoryWarning
  35. {
  36. // Releases the view if it doesn't have a superview.
  37. [super didReceiveMemoryWarning];
  38. // Release any cached data, images, etc that aren't in use.
  39. }
  40. #pragma mark - Playback control
  41. - (void)playPressed {
  42. playButton.hidden = YES;
  43. pauseButton.hidden = NO;
  44. User *user = [User currentUser];
  45. [user.configuration setProperty:PropertyMediaState toValue:[NSNumber numberWithInt:MediaStatePlaying]];
  46. [user pushConfiguration];
  47. }
  48. - (void)pausePressed {
  49. playButton.hidden = NO;
  50. pauseButton.hidden = YES;
  51. User *user = [User currentUser];
  52. [user.configuration setProperty:PropertyMediaState toValue:[NSNumber numberWithInt:MediaStatePaused]];
  53. [user pushConfiguration];
  54. }
  55. #pragma mark - View lifecycle
  56. - (void)viewDidLoad
  57. {
  58. [super viewDidLoad];
  59. // Do any additional setup after loading the view from its nib.
  60. }
  61. - (void)viewDidUnload
  62. {
  63. [super viewDidUnload];
  64. // Release any retained subviews of the main view.
  65. // e.g. self.myOutlet = nil;
  66. }
  67. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  68. {
  69. // Return YES for supported orientations
  70. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  71. }
  72. @end