redribben

ViewController.m

Aug 18th, 2014
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  ViewController.m
  3. //  Радио СВЕТ
  4. //
  5. //  Created by CBET on 10/21/13.
  6. //  Copyright (c) 2013 Радио CBET. All rights reserved.
  7. //
  8.  
  9. #import "ViewController.h"
  10.  
  11.  
  12. @interface ViewController ()
  13. @property (nonatomic) BOOL playButtonClicked;  //the property for identifying if the stream is playing or not
  14. @property (nonatomic) BOOL connectionStopped;  //the property for identifying if the stream was stopped
  15.  
  16. //from hollace
  17. @property (nonatomic, assign, readwrite) BOOL playing;
  18.  
  19. - (void)tearDownAudio;
  20. - (void)setUpAudio;
  21. - (void)start;
  22. @end
  23.  
  24.  
  25.  
  26. @implementation ViewController {
  27.     BMHttpAudioStreamManager* _streamManager;
  28. }
  29.  
  30.  
  31. // Allocate and initialize BMHttpAudioStreamManager object and assign to the instance variable of ViewController
  32. - (instancetype) initWithNibName:(NSString *)nibNameOrNil
  33.                           bundle:(NSBundle *)nibBundleOrNil {
  34.     if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
  35.         _streamManager = [[BMHttpAudioStreamManager alloc] init];
  36.     }
  37.     return self;
  38. }
  39.  
  40. - (void)viewDidLoad {
  41.     [[UIApplication sharedApplication] setIdleTimerDisabled:YES]; //disable idle timer
  42.     [super viewDidLoad];
  43. }
  44.  
  45.  
  46. - (void)viewDidUnload {
  47.     [super viewDidUnload];
  48.     // Release any retained subviews of the main view.
  49.     // e.g. self.myOutlet = nil;
  50.    
  51.     // Supposed to play sound when the audio switch is turned off
  52.     [[AVAudioSession sharedInstance]
  53.      setCategory: AVAudioSessionCategoryPlayback
  54.      error: nil];
  55. }
  56.  
  57.  
  58. - (void)viewDidAppear:(BOOL)animated {
  59.     [super viewDidAppear:animated];
  60.    
  61.     MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:self.viewVolume.bounds];
  62.     [self.viewVolume addSubview:volumeView];
  63.     [volumeView sizeToFit];
  64. }
  65.  
  66.  
  67. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  68.     // Return YES for supported orientations
  69.     return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
  70. }
  71.  
  72.  
  73. - (IBAction)selectingQuality:(id)sender {
  74.     switch (self.qualitySelectionSwitch.selectedSegmentIndex) {
  75.         case 0: self.whichQualitySelected.text = @"64 kbps";
  76.             //        RADIO_LOCATION = "http://pdxrr.com:8094";
  77.             break;
  78.         case 1: self.whichQualitySelected.text = @"96 kbps";
  79.             //        RADIO_LOCATION = "http://pdxrr.com:8092"
  80.             break;
  81.         case 2: self.whichQualitySelected.text = @"128 kbps";
  82.             //        RADIO_LOCATION = "http://pdxrr.com:8090";
  83.             break;
  84.     }
  85. }
  86.  
  87.  
  88. - (IBAction)play:(id)sender {
  89.     if (!self.playButtonClicked) {
  90.         [_streamManager connectionStart];
  91.         self.connectionStopped = NO;
  92.     }
  93. }
  94.  
  95. - (IBAction)stop:(id)sender {
  96.     if (self.playButtonClicked) {
  97.         [_streamManager stopRadio];
  98.         self.playButtonClicked = NO;
  99.         self.connectionStopped = YES;
  100.         //        [self tearDownPlayQueue];
  101.     }
  102. }
  103.  
  104.  
  105.  
  106. @end
Advertisement
Add Comment
Please, Sign In to add comment