Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ViewController.m
- // Радио СВЕТ
- //
- // Created by CBET on 10/21/13.
- // Copyright (c) 2013 Радио CBET. All rights reserved.
- //
- #import "ViewController.h"
- @interface ViewController ()
- @property (nonatomic) BOOL playButtonClicked; //the property for identifying if the stream is playing or not
- @property (nonatomic) BOOL connectionStopped; //the property for identifying if the stream was stopped
- //from hollace
- @property (nonatomic, assign, readwrite) BOOL playing;
- - (void)tearDownAudio;
- - (void)setUpAudio;
- - (void)start;
- @end
- @implementation ViewController {
- BMHttpAudioStreamManager* _streamManager;
- }
- // Allocate and initialize BMHttpAudioStreamManager object and assign to the instance variable of ViewController
- - (instancetype) initWithNibName:(NSString *)nibNameOrNil
- bundle:(NSBundle *)nibBundleOrNil {
- if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
- _streamManager = [[BMHttpAudioStreamManager alloc] init];
- }
- return self;
- }
- - (void)viewDidLoad {
- [[UIApplication sharedApplication] setIdleTimerDisabled:YES]; //disable idle timer
- [super viewDidLoad];
- }
- - (void)viewDidUnload {
- [super viewDidUnload];
- // Release any retained subviews of the main view.
- // e.g. self.myOutlet = nil;
- // Supposed to play sound when the audio switch is turned off
- [[AVAudioSession sharedInstance]
- setCategory: AVAudioSessionCategoryPlayback
- error: nil];
- }
- - (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
- MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:self.viewVolume.bounds];
- [self.viewVolume addSubview:volumeView];
- [volumeView sizeToFit];
- }
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- // Return YES for supported orientations
- return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
- }
- - (IBAction)selectingQuality:(id)sender {
- switch (self.qualitySelectionSwitch.selectedSegmentIndex) {
- case 0: self.whichQualitySelected.text = @"64 kbps";
- // RADIO_LOCATION = "http://pdxrr.com:8094";
- break;
- case 1: self.whichQualitySelected.text = @"96 kbps";
- // RADIO_LOCATION = "http://pdxrr.com:8092"
- break;
- case 2: self.whichQualitySelected.text = @"128 kbps";
- // RADIO_LOCATION = "http://pdxrr.com:8090";
- break;
- }
- }
- - (IBAction)play:(id)sender {
- if (!self.playButtonClicked) {
- [_streamManager connectionStart];
- self.connectionStopped = NO;
- }
- }
- - (IBAction)stop:(id)sender {
- if (self.playButtonClicked) {
- [_streamManager stopRadio];
- self.playButtonClicked = NO;
- self.connectionStopped = YES;
- // [self tearDownPlayQueue];
- }
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment