Permalink
Browse files

super cool audio!

  • Loading branch information...
1 parent e248c65 commit 6cfebc88b372dadddd664cefee724b0d95aadde9 @jrwren committed Feb 10, 2012
View
19 audiospike.xcodeproj/project.pbxproj
@@ -15,29 +15,35 @@
A19B535D14E57198001F43BC /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A19B535C14E57198001F43BC /* AppDelegate.m */; };
A19B536014E57199001F43BC /* MainStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A19B535E14E57198001F43BC /* MainStoryboard.storyboard */; };
A19B536314E57199001F43BC /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A19B536214E57199001F43BC /* ViewController.m */; };
+ A19B536A14E57308001F43BC /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A19B536914E57308001F43BC /* AVFoundation.framework */; };
+ A19B536C14E5A069001F43BC /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A19B536B14E5A069001F43BC /* MediaPlayer.framework */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
A19B534814E57198001F43BC /* audiospike.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = audiospike.app; sourceTree = BUILT_PRODUCTS_DIR; };
A19B534C14E57198001F43BC /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
A19B534E14E57198001F43BC /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
A19B535014E57198001F43BC /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
- A19B535414E57198001F43BC /* audiospike-Info.plist */ = {isa = PBXFileReference; path = "audiospike-Info.plist"; sourceTree = "<group>"; };
+ A19B535414E57198001F43BC /* audiospike-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "audiospike-Info.plist"; sourceTree = "<group>"; };
A19B535614E57198001F43BC /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
A19B535814E57198001F43BC /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
- A19B535A14E57198001F43BC /* audiospike-Prefix.pch */ = {isa = PBXFileReference; path = "audiospike-Prefix.pch"; sourceTree = "<group>"; };
- A19B535B14E57198001F43BC /* AppDelegate.h */ = {isa = PBXFileReference; path = AppDelegate.h; sourceTree = "<group>"; };
+ A19B535A14E57198001F43BC /* audiospike-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "audiospike-Prefix.pch"; sourceTree = "<group>"; };
+ A19B535B14E57198001F43BC /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
A19B535C14E57198001F43BC /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
A19B535F14E57199001F43BC /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard.storyboard; sourceTree = "<group>"; };
- A19B536114E57199001F43BC /* ViewController.h */ = {isa = PBXFileReference; path = ViewController.h; sourceTree = "<group>"; };
+ A19B536114E57199001F43BC /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
A19B536214E57199001F43BC /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
+ A19B536914E57308001F43BC /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
+ A19B536B14E5A069001F43BC /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
A19B534514E57198001F43BC /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ A19B536C14E5A069001F43BC /* MediaPlayer.framework in Frameworks */,
+ A19B536A14E57308001F43BC /* AVFoundation.framework in Frameworks */,
A19B534D14E57198001F43BC /* UIKit.framework in Frameworks */,
A19B534F14E57198001F43BC /* Foundation.framework in Frameworks */,
A19B535114E57198001F43BC /* CoreGraphics.framework in Frameworks */,
@@ -67,6 +73,8 @@
A19B534B14E57198001F43BC /* Frameworks */ = {
isa = PBXGroup;
children = (
+ A19B536B14E5A069001F43BC /* MediaPlayer.framework */,
+ A19B536914E57308001F43BC /* AVFoundation.framework */,
A19B534C14E57198001F43BC /* UIKit.framework */,
A19B534E14E57198001F43BC /* Foundation.framework */,
A19B535014E57198001F43BC /* CoreGraphics.framework */,
@@ -194,7 +202,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
- "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Jay Wren (VAX2J7EHVA)";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
@@ -209,6 +217,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ "PROVISIONING_PROFILE[sdk=iphoneos*]" = "5BADBEB3-43A3-4645-8DB7-D09D736B2B3D";
SDKROOT = iphoneos;
};
name = Debug;
View
8 audiospike/ViewController.h
@@ -9,5 +9,13 @@
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
+{
+ BOOL paused;
+}
+@property (strong, nonatomic) IBOutlet UILabel *titleLabel;
+@property (strong, nonatomic) IBOutlet UIButton *pauseButton;
+@property (strong, nonatomic) IBOutlet UISlider *volumeSlider;
+- (IBAction)buttonTouched:(id)sender;
+@property (strong, nonatomic) IBOutlet UIView *mpVolumeViewParentView;
@end
View
87 audiospike/ViewController.m
@@ -7,8 +7,14 @@
//
#import "ViewController.h"
+#import <AVFoundation/AVFoundation.h>
+#import <MediaPlayer/MPVolumeView.h>
@implementation ViewController
+@synthesize mpVolumeViewParentView;
+@synthesize titleLabel;
+@synthesize pauseButton;
+@synthesize volumeSlider;
- (void)didReceiveMemoryWarning
{
@@ -17,15 +23,78 @@ - (void)didReceiveMemoryWarning
}
#pragma mark - View lifecycle
+AVPlayer *player;
+-(void)playStream{
+
+ NSURL *url = [NSURL URLWithString:@"http://66.180.202.151:8000/live"];
+
+ AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:url];
+
+ [playerItem addObserver:self forKeyPath:@"status" options:0 context:nil];
+ [playerItem addObserver:self forKeyPath:@"timedMetadata" options:0 context:nil];
+ player = [AVPlayer playerWithPlayerItem:playerItem];
+
+ [player play];
+
+
+}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
+ [self playStream];
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(volumeChanged:)
+ name:@"AVSystemController_SystemVolumeDidChangeNotification"
+ object:nil];
+
+ mpVolumeViewParentView.backgroundColor = [UIColor clearColor];
+
+ MPVolumeView *myVolumeView =
+
+ [[MPVolumeView alloc] initWithFrame: mpVolumeViewParentView.bounds];
+
+ [mpVolumeViewParentView addSubview: myVolumeView];
+
+
+}
+- (void)volumeChanged:(NSNotification *)notification
+{
+ float volume =
+ [[[notification userInfo]
+ objectForKey:@"AVSystemController_AudioVolumeNotificationParameter"]
+ floatValue];
+
+ volumeSlider.value = volume;
+ NSLog(@"volumeChanged:%f", volume);
+}
+
+
+-(void)observeValueForKeyPath:(NSString *)keyPath
+ofObject:(id)object
+change:(NSDictionary *)change
+context:(void *)context
+{
+ NSLog(@"path: %@", keyPath);
+ NSLog(@"tracks:%@ ", player.currentItem.tracks);
+
+ for (AVMetadataItem *metaItem in player.currentItem.timedMetadata) {
+ NSLog(@"%@ %@",[metaItem commonKey], [metaItem value]);
+ }
+ if ([player.currentItem.timedMetadata count]>0) {
+ AVMetadataItem *metaItem = [player.currentItem.timedMetadata objectAtIndex:0];
+ titleLabel.text = (NSString*)[metaItem value];
+ }
}
- (void)viewDidUnload
{
+ [self setTitleLabel:nil];
+ [self setPauseButton:nil];
+ [self setVolumeSlider:nil];
+ [self setMpVolumeViewParentView:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
@@ -57,4 +126,22 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
+- (IBAction)buttonTouched:(id)sender {
+
+ if (player.rate==1.0)
+ {
+ //[playerItem addObserver:self forKeyPath:@"timedMetadata" options:0 context:nil];
+ //[player.currentItem removeObserver:self forKeyPath:@"timedMetadata" context:nil];
+ //[player.currentItem removeObserver:self forKeyPath:@"status" context:nil];
+ [player pause];
+ //player = nil;
+ [pauseButton setTitle:@"Play" forState:UIControlStateNormal];
+ }
+ else
+ {
+ //[self playStream];
+ [player play];
+ [pauseButton setTitle:@"Pause" forState:UIControlStateNormal];
+ }
+}
@end
View
39 audiospike/en.lproj/MainStoryboard.storyboard
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.0" toolsVersion="1906" systemVersion="11A511" targetRuntime="iOS.CocoaTouch" nextObjectID="6" propertyAccessControl="none" initialViewController="2">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.0" toolsVersion="1938" systemVersion="11D50b" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="2">
<dependencies>
<development defaultVersion="4200" identifier="xcode"/>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="902"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="933"/>
</dependencies>
<scenes>
<scene sceneID="5">
@@ -12,9 +12,42 @@
<view key="view" contentMode="scaleToFill" id="3">
<rect key="frame" x="0.0" y="20" width="320" height="460"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
- <subviews/>
+ <subviews>
+ <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="" lineBreakMode="tailTruncation" minimumFontSize="10" id="ve9-8Q-HTt">
+ <rect key="frame" x="20" y="20" width="280" height="21"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
+ <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+ <nil key="highlightedColor"/>
+ </label>
+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="qYO-bY-Ohr">
+ <rect key="frame" x="20" y="49" width="69" height="31"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <fontDescription key="fontDescription" type="boldSystem" size="button"/>
+ <state key="normal" title="Pause">
+ <color key="titleColor" red="0.19607843137254902" green="0.30980392156862746" blue="0.52156862745098043" alpha="1" colorSpace="calibratedRGB"/>
+ <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
+ </state>
+ <state key="highlighted">
+ <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+ </state>
+ <connections>
+ <action selector="buttonTouched:" destination="2" eventType="touchUpInside" id="vX9-s2-QqM"/>
+ </connections>
+ </button>
+ <view contentMode="scaleToFill" id="p2E-vf-itU">
+ <rect key="frame" x="20" y="409" width="280" height="31"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+ </view>
+ </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
+ <connections>
+ <outlet property="mpVolumeViewParentView" destination="p2E-vf-itU" id="b4l-3r-2Gz"/>
+ <outlet property="pauseButton" destination="qYO-bY-Ohr" id="A4v-6W-bFO"/>
+ <outlet property="titleLabel" destination="ve9-8Q-HTt" id="0B3-Ql-x5a"/>
+ </connections>
</viewController>
</objects>
</scene>

0 comments on commit 6cfebc8

Please sign in to comment.