Added source and gitignore

This commit is contained in:
Thong Nguyen 2012-09-02 00:07:06 +01:00
parent 205317046b
commit bf23483063
21 changed files with 3491 additions and 0 deletions

View File

@ -0,0 +1,340 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
A186B4E4157F80E700BD0084 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A186B4E3157F80E700BD0084 /* UIKit.framework */; };
A186B4E6157F80E700BD0084 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A186B4E5157F80E700BD0084 /* Foundation.framework */; };
A186B4EE157F80E700BD0084 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A186B4EC157F80E700BD0084 /* InfoPlist.strings */; };
A186B4F0157F80E700BD0084 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A186B4EF157F80E700BD0084 /* main.m */; };
A186B4F4157F80E700BD0084 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A186B4F3157F80E700BD0084 /* AppDelegate.m */; };
A186B50C157F813100BD0084 /* AudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = A186B501157F813100BD0084 /* AudioPlayer.m */; };
A186B50D157F813100BD0084 /* CoreFoundationDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = A186B503157F813100BD0084 /* CoreFoundationDataSource.m */; };
A186B50E157F813100BD0084 /* DataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = A186B505157F813100BD0084 /* DataSource.m */; };
A186B50F157F813100BD0084 /* HttpDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = A186B507157F813100BD0084 /* HttpDataSource.m */; };
A186B510157F813100BD0084 /* LocalFileDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = A186B509157F813100BD0084 /* LocalFileDataSource.m */; };
A186B511157F813100BD0084 /* AudioPlayerView.m in Sources */ = {isa = PBXBuildFile; fileRef = A186B50B157F813100BD0084 /* AudioPlayerView.m */; };
A186B514157F817500BD0084 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A186B513157F817500BD0084 /* AudioToolbox.framework */; };
A186B518157F818900BD0084 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A186B517157F818900BD0084 /* CoreFoundation.framework */; };
A186B51A157F819500BD0084 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A186B519157F819500BD0084 /* CFNetwork.framework */; };
A186B51D157F825400BD0084 /* sample.m4a in Resources */ = {isa = PBXBuildFile; fileRef = A186B51C157F820F00BD0084 /* sample.m4a */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
A186B4DF157F80E600BD0084 /* Audjustable.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Audjustable.app; sourceTree = BUILT_PRODUCTS_DIR; };
A186B4E3157F80E700BD0084 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
A186B4E5157F80E700BD0084 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
A186B4E7157F80E700BD0084 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
A186B4EB157F80E700BD0084 /* Audjustable-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Audjustable-Info.plist"; sourceTree = "<group>"; };
A186B4ED157F80E700BD0084 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
A186B4EF157F80E700BD0084 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
A186B4F1157F80E700BD0084 /* Audjustable-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Audjustable-Prefix.pch"; sourceTree = "<group>"; };
A186B4F2157F80E700BD0084 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
A186B4F3157F80E700BD0084 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
A186B500157F813100BD0084 /* AudioPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioPlayer.h; sourceTree = "<group>"; };
A186B501157F813100BD0084 /* AudioPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioPlayer.m; sourceTree = "<group>"; };
A186B502157F813100BD0084 /* CoreFoundationDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreFoundationDataSource.h; sourceTree = "<group>"; };
A186B503157F813100BD0084 /* CoreFoundationDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CoreFoundationDataSource.m; sourceTree = "<group>"; };
A186B504157F813100BD0084 /* DataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataSource.h; sourceTree = "<group>"; };
A186B505157F813100BD0084 /* DataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DataSource.m; sourceTree = "<group>"; };
A186B506157F813100BD0084 /* HttpDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HttpDataSource.h; sourceTree = "<group>"; };
A186B507157F813100BD0084 /* HttpDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HttpDataSource.m; sourceTree = "<group>"; };
A186B508157F813100BD0084 /* LocalFileDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalFileDataSource.h; sourceTree = "<group>"; };
A186B509157F813100BD0084 /* LocalFileDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocalFileDataSource.m; sourceTree = "<group>"; };
A186B50A157F813100BD0084 /* AudioPlayerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioPlayerView.h; sourceTree = "<group>"; };
A186B50B157F813100BD0084 /* AudioPlayerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioPlayerView.m; sourceTree = "<group>"; };
A186B513157F817500BD0084 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
A186B517157F818900BD0084 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
A186B519157F819500BD0084 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
A186B51C157F820F00BD0084 /* sample.m4a */ = {isa = PBXFileReference; lastKnownFileType = file; path = sample.m4a; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
A186B4DC157F80E600BD0084 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
A186B51A157F819500BD0084 /* CFNetwork.framework in Frameworks */,
A186B518157F818900BD0084 /* CoreFoundation.framework in Frameworks */,
A186B514157F817500BD0084 /* AudioToolbox.framework in Frameworks */,
A186B4E4157F80E700BD0084 /* UIKit.framework in Frameworks */,
A186B4E6157F80E700BD0084 /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
A186B4D4157F80E600BD0084 = {
isa = PBXGroup;
children = (
A186B4E9157F80E700BD0084 /* Audjustable */,
A186B4E2157F80E700BD0084 /* Frameworks */,
A186B4E0157F80E600BD0084 /* Products */,
);
sourceTree = "<group>";
};
A186B4E0157F80E600BD0084 /* Products */ = {
isa = PBXGroup;
children = (
A186B4DF157F80E600BD0084 /* Audjustable.app */,
);
name = Products;
sourceTree = "<group>";
};
A186B4E2157F80E700BD0084 /* Frameworks */ = {
isa = PBXGroup;
children = (
A186B519157F819500BD0084 /* CFNetwork.framework */,
A186B517157F818900BD0084 /* CoreFoundation.framework */,
A186B513157F817500BD0084 /* AudioToolbox.framework */,
A186B4E3157F80E700BD0084 /* UIKit.framework */,
A186B4E5157F80E700BD0084 /* Foundation.framework */,
A186B4E7157F80E700BD0084 /* CoreGraphics.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
A186B4E9157F80E700BD0084 /* Audjustable */ = {
isa = PBXGroup;
children = (
A186B4FE157F813100BD0084 /* Classes */,
A186B4F2157F80E700BD0084 /* AppDelegate.h */,
A186B4F3157F80E700BD0084 /* AppDelegate.m */,
A186B4EA157F80E700BD0084 /* Supporting Files */,
);
path = Audjustable;
sourceTree = "<group>";
};
A186B4EA157F80E700BD0084 /* Supporting Files */ = {
isa = PBXGroup;
children = (
A186B51B157F81D900BD0084 /* Resources */,
A186B4EB157F80E700BD0084 /* Audjustable-Info.plist */,
A186B4EC157F80E700BD0084 /* InfoPlist.strings */,
A186B4EF157F80E700BD0084 /* main.m */,
A186B4F1157F80E700BD0084 /* Audjustable-Prefix.pch */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
A186B4FE157F813100BD0084 /* Classes */ = {
isa = PBXGroup;
children = (
A186B4FF157F813100BD0084 /* AudioPlayer */,
A186B50A157F813100BD0084 /* AudioPlayerView.h */,
A186B50B157F813100BD0084 /* AudioPlayerView.m */,
);
path = Classes;
sourceTree = "<group>";
};
A186B4FF157F813100BD0084 /* AudioPlayer */ = {
isa = PBXGroup;
children = (
A186B500157F813100BD0084 /* AudioPlayer.h */,
A186B501157F813100BD0084 /* AudioPlayer.m */,
A186B502157F813100BD0084 /* CoreFoundationDataSource.h */,
A186B503157F813100BD0084 /* CoreFoundationDataSource.m */,
A186B504157F813100BD0084 /* DataSource.h */,
A186B505157F813100BD0084 /* DataSource.m */,
A186B506157F813100BD0084 /* HttpDataSource.h */,
A186B507157F813100BD0084 /* HttpDataSource.m */,
A186B508157F813100BD0084 /* LocalFileDataSource.h */,
A186B509157F813100BD0084 /* LocalFileDataSource.m */,
);
path = AudioPlayer;
sourceTree = "<group>";
};
A186B51B157F81D900BD0084 /* Resources */ = {
isa = PBXGroup;
children = (
A186B51C157F820F00BD0084 /* sample.m4a */,
);
name = Resources;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
A186B4DE157F80E600BD0084 /* Audjustable */ = {
isa = PBXNativeTarget;
buildConfigurationList = A186B4F7157F80E700BD0084 /* Build configuration list for PBXNativeTarget "Audjustable" */;
buildPhases = (
A186B4DB157F80E600BD0084 /* Sources */,
A186B4DC157F80E600BD0084 /* Frameworks */,
A186B4DD157F80E600BD0084 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = Audjustable;
productName = Audjustable;
productReference = A186B4DF157F80E600BD0084 /* Audjustable.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
A186B4D6157F80E600BD0084 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0430;
};
buildConfigurationList = A186B4D9157F80E600BD0084 /* Build configuration list for PBXProject "Audjustable" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = A186B4D4157F80E600BD0084;
productRefGroup = A186B4E0157F80E600BD0084 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
A186B4DE157F80E600BD0084 /* Audjustable */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
A186B4DD157F80E600BD0084 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A186B4EE157F80E700BD0084 /* InfoPlist.strings in Resources */,
A186B51D157F825400BD0084 /* sample.m4a in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
A186B4DB157F80E600BD0084 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A186B4F0157F80E700BD0084 /* main.m in Sources */,
A186B4F4157F80E700BD0084 /* AppDelegate.m in Sources */,
A186B50C157F813100BD0084 /* AudioPlayer.m in Sources */,
A186B50D157F813100BD0084 /* CoreFoundationDataSource.m in Sources */,
A186B50E157F813100BD0084 /* DataSource.m in Sources */,
A186B50F157F813100BD0084 /* HttpDataSource.m in Sources */,
A186B510157F813100BD0084 /* LocalFileDataSource.m in Sources */,
A186B511157F813100BD0084 /* AudioPlayerView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
A186B4EC157F80E700BD0084 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
A186B4ED157F80E700BD0084 /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
A186B4F5157F80E700BD0084 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
A186B4F6157F80E700BD0084 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
A186B4F8157F80E700BD0084 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Audjustable/Audjustable-Prefix.pch";
INFOPLIST_FILE = "Audjustable/Audjustable-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Debug;
};
A186B4F9157F80E700BD0084 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Audjustable/Audjustable-Prefix.pch";
INFOPLIST_FILE = "Audjustable/Audjustable-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
A186B4D9157F80E600BD0084 /* Build configuration list for PBXProject "Audjustable" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A186B4F5157F80E700BD0084 /* Debug */,
A186B4F6157F80E700BD0084 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
A186B4F7157F80E700BD0084 /* Build configuration list for PBXNativeTarget "Audjustable" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A186B4F8157F80E700BD0084 /* Debug */,
A186B4F9157F80E700BD0084 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = A186B4D6157F80E600BD0084 /* Project object */;
}

20
Audjustable/AppDelegate.h Normal file
View File

@ -0,0 +1,20 @@
//
// AppDelegate.h
// BlueCucumber-AudioPlayer
//
// Created by Thong Nguyen on 01/06/2012.
// Copyright (c) 2012 Thong Nguyen All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AudioPlayerView.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate, AudioPlayerViewDelegate>
{
@private
AudioPlayer* audioPlayer;
}
@property (strong, nonatomic) UIWindow *window;
@end

50
Audjustable/AppDelegate.m Normal file
View File

@ -0,0 +1,50 @@
//
// AppDelegate.m
// BlueCucumber-AudioPlayer
//
// Created by Thong Nguyen on 01/06/2012.
// Copyright (c) 2012 Thong Nguyen All rights reserved.
//
#import "AppDelegate.h"
#import "AudioPlayerView.h"
@implementation AppDelegate
@synthesize window = _window;
-(BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
audioPlayer = [[AudioPlayer alloc] init];
AudioPlayerView* audioPlayerView = [[AudioPlayerView alloc] initWithFrame:self.window.bounds];
audioPlayerView.delegate = self;
audioPlayerView.audioPlayer = audioPlayer;
[self.window addSubview:audioPlayerView];
[self.window makeKeyAndVisible];
return YES;
}
-(void) audioPlayerViewPlayFromHTTPSelected:(AudioPlayerView*)audioPlayerView
{
NSURL* url = [NSURL URLWithString:@"http://audjustable.googlecode.com/files/sample.m4a"];
[audioPlayer setDataSource:[audioPlayer dataSourceFromURL:url] withQueueItemId:url];
}
-(void) audioPlayerViewPlayFromLocalFileSelected:(AudioPlayerView *)audioPlayerView
{
NSString * path = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"m4a"];
NSURL* url = [NSURL fileURLWithPath:path];
[audioPlayer setDataSource:[audioPlayer dataSourceFromURL:url] withQueueItemId:url];
}
@end

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>AbstractPath.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@ -0,0 +1,14 @@
//
// Prefix header for all source files of the 'Audjustable' target in the 'Audjustable' project
//
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iOS SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif

View File

@ -0,0 +1,192 @@
/**********************************************************************************
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
Inspired by Matt Gallagher's AudioStreamer:
https://github.com/mattgallagher/AudioStreamer
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the <organization>.
4. Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************/
#import <Foundation/Foundation.h>
#import <pthread.h>
#import "DataSource.h"
#include <AudioToolbox/AudioToolbox.h>
#define AudioPlayerDefaultNumberOfAudioQueueBuffers (8 * 1024)
typedef enum
{
AudioPlayerInternalStateInitialised = 0,
AudioPlayerInternalStateRunning = 1,
AudioPlayerInternalStatePlaying = (1 << 1) | AudioPlayerInternalStateRunning,
AudioPlayerInternalStateStartingThread = (1 << 2) | AudioPlayerInternalStateRunning,
AudioPlayerInternalStateWaitingForData = (1 << 3) | AudioPlayerInternalStateRunning,
AudioPlayerInternalStateWaitingForQueueToStart = (1 << 5) | AudioPlayerInternalStateRunning,
AudioPlayerInternalStatePaused = (1 << 6) | AudioPlayerInternalStateRunning,
AudioPlayerInternalStateStopping = (1 << 7),
AudioPlayerInternalStateStopped = (1 << 8),
AudioPlayerInternalStateDisposed = (1 << 9),
AudioPlayerInternalStateError = (1 << 10)
}
AudioPlayerInternalState;
typedef enum
{
AudioPlayerStateReady,
AudioPlayerStateRunning = 1,
AudioPlayerStatePlaying = (1 << 1) | AudioPlayerStateRunning,
AudioPlayerStatePaused = (1 << 2) | AudioPlayerStateRunning,
AudioPlayerStateStopped = (1 << 3),
AudioPlayerStateError = (1 << 4),
AudioPlayerStateDisposed = (1 << 5)
}
AudioPlayerState;
typedef enum
{
AudioPlayerStopReasonNoStop = 0,
AudioPlayerStopReasonEof,
AudioPlayerStopReasonUserAction,
AudioPlayerStopReasonUserActionFlushStop
}
AudioPlayerStopReason;
typedef enum
{
AudioPlayerErrorNone = 0,
AudioPlayerErrorDataSource,
AudioPlayerErrorStreamParseBytesFailed,
AudioPlayerErrorDataNotFound,
AudioPlayerErrorQueueStartFailed,
AudioPlayerErrorQueuePauseFailed,
AudioPlayerErrorUnknownBuffer,
AudioPlayerErrorQueueStopFailed,
AudioPlayerErrorOther
}
AudioPlayerErrorCode;
@class AudioPlayer;
@protocol AudioPlayerDelegate <NSObject>
-(void) audioPlayer:(AudioPlayer*)audioPlayer stateChanged:(AudioPlayerState)state;
-(void) audioPlayer:(AudioPlayer*)audioPlayer didEncounterError:(AudioPlayerErrorCode)errorCode;
-(void) audioPlayer:(AudioPlayer*)audioPlayer didStartPlayingQueueItemId:(NSObject*)queueItemId;
-(void) audioPlayer:(AudioPlayer*)audioPlayer didFinishBufferingSourceWithQueueItemId:(NSObject*)queueItemId;
-(void) audioPlayer:(AudioPlayer*)audioPlayer didFinishPlayingQueueItemId:(NSObject*)queueItemId withReason:(AudioPlayerStopReason)stopReason andProgress:(double)progress andDuration:(double)duration;
@optional
-(void) audioPlayer:(AudioPlayer*)audioPlayer internalStateChanged:(AudioPlayerInternalState)state;
@end
@class QueueEntry;
typedef struct
{
AudioQueueBufferRef ref;
int bufferIndex;
}
AudioQueueBufferRefLookupEntry;
@interface AudioPlayer : NSObject<DataSourceDelegate>
{
@private
UInt8* readBuffer;
int readBufferSize;
dispatch_queue_t fastApiSerialQueue;
QueueEntry* currentlyPlayingEntry;
QueueEntry* currentlyReadingEntry;
NSMutableArray* upcomingQueue;
NSMutableArray* bufferingQueue;
AudioQueueBufferRef* audioQueueBuffer;
AudioQueueBufferRefLookupEntry* audioQueueBufferLookup;
int audioQueueBufferRefLookupCount;
int audioQueueBufferCount;
AudioStreamPacketDescription* packetDescs;
bool* bufferUsed;
int numberOfBuffersUsed;
AudioQueueRef audioQueue;
AudioStreamBasicDescription currentAudioStreamBasicDescription;
NSThread* playbackThread;
NSRunLoop* playbackThreadRunLoop;
NSConditionLock* threadFinishedCondLock;
AudioFileStreamID audioFileStream;
BOOL discontinuous;
BOOL nextIsIncompatible;
int bytesFilled;
int packetsFilled;
int fillBufferIndex;
UIBackgroundTaskIdentifier backgroundTaskId;
AudioPlayerErrorCode errorCode;
AudioPlayerStopReason stopReason;
pthread_mutex_t queueBuffersMutex;
pthread_cond_t queueBufferReadyCondition;
volatile BOOL disposeWasRequested;
volatile BOOL seekToTimeWasRequested;
volatile BOOL newFileToPlay;
volatile double requestedSeekTime;
volatile BOOL audioQueueFlushing;
volatile SInt64 audioPacketsReadCount;
volatile SInt64 audioPacketsPlayedCount;
}
@property (readonly) double duration;
@property (readonly) double progress;
@property (readwrite) AudioPlayerState state;
@property (readonly) AudioPlayerStopReason stopReason;
@property (readwrite, unsafe_unretained) id<AudioPlayerDelegate> delegate;
-(id) init;
-(id) initWithNumberOfAudioQueueBuffers:(int)numberOfAudioQueueBuffers andReadBufferSize:(int)readBufferSizeIn;
-(DataSource*) dataSourceFromURL:(NSURL*)url;
-(void) play:(NSURL*)url;
-(void) queueDataSource:(DataSource*)dataSource withQueueItemId:(NSObject*)queueItemId;
-(void) setDataSource:(DataSource*)dataSourceIn withQueueItemId:(NSObject*)queueItemId;
-(void) seekToTime:(double)value;
-(void) pause;
-(void) resume;
-(void) stop;
-(void) flushStop;
-(void) dispose;
@end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,57 @@
/**********************************************************************************
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the <organization>.
4. Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************/
#import "DataSource.h"
@class CoreFoundationDataSource;
@interface CoreFoundationDataSourceClientInfo : NSObject
@property (readwrite) CFReadStreamRef readStreamRef;
@property (readwrite, retain) CoreFoundationDataSource* datasource;
@end
@interface CoreFoundationDataSource : DataSource
{
@protected
CFReadStreamRef stream;
NSRunLoop* eventsRunLoop;
}
-(BOOL) reregisterForEvents;
-(void) dataAvailable;
-(void) eof;
-(void) errorOccured;
@end

View File

@ -0,0 +1,148 @@
/**********************************************************************************
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the <organization>.
4. Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************/
#import "CoreFoundationDataSource.h"
static void ReadStreamCallbackProc(CFReadStreamRef stream, CFStreamEventType eventType, void* inClientInfo)
{
CoreFoundationDataSource* datasource = (__bridge CoreFoundationDataSource*)inClientInfo;
switch (eventType)
{
case kCFStreamEventErrorOccurred:
[datasource errorOccured];
break;
case kCFStreamEventEndEncountered:
[datasource eof];
break;
case kCFStreamEventHasBytesAvailable:
[datasource dataAvailable];
break;
}
}
@implementation CoreFoundationDataSourceClientInfo
@synthesize readStreamRef, datasource;
@end
@implementation CoreFoundationDataSource
-(void) dataAvailable
{
[self.delegate dataSourceDataAvailable:self];
}
-(void) eof
{
[self.delegate dataSourceEof:self];
}
-(void) errorOccured
{
[self.delegate dataSourceErrorOccured:self];
}
-(void) dealloc
{
if (stream)
{
[self unregisterForEvents];
CFReadStreamClose(stream);
stream = 0;
}
}
-(void) seekToOffset:(long long)offset
{
}
-(int) readIntoBuffer:(UInt8*)buffer withSize:(int)size
{
return CFReadStreamRead(stream, buffer, size);
}
-(void) unregisterForEvents
{
if (stream)
{
CFReadStreamSetClient(stream, kCFStreamEventHasBytesAvailable | kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered, NULL, NULL);
CFReadStreamUnscheduleFromRunLoop(stream, [eventsRunLoop getCFRunLoop], kCFRunLoopCommonModes);
}
}
-(BOOL) reregisterForEvents
{
if (eventsRunLoop && stream)
{
CFStreamClientContext context = {0, (__bridge void*)self, NULL, NULL, NULL};
CFReadStreamSetClient(stream, kCFStreamEventHasBytesAvailable | kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered, ReadStreamCallbackProc, &context);
CFReadStreamScheduleWithRunLoop(stream, [eventsRunLoop getCFRunLoop], kCFRunLoopCommonModes);
return YES;
}
return NO;
}
-(BOOL) registerForEvents:(NSRunLoop*)runLoop
{
eventsRunLoop = runLoop;
if (stream)
{
CFStreamClientContext context = {0, (__bridge void*)self, NULL, NULL, NULL};
CFReadStreamSetClient(stream, kCFStreamEventHasBytesAvailable | kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered, ReadStreamCallbackProc, &context);
CFReadStreamScheduleWithRunLoop(stream, [eventsRunLoop getCFRunLoop], kCFRunLoopCommonModes);
return YES;
}
return NO;
}
-(BOOL) hasBytesAvailable
{
if (!stream)
{
return NO;
}
return CFReadStreamHasBytesAvailable(stream);
}
@end

View File

@ -0,0 +1,59 @@
/**********************************************************************************
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the <organization>.
4. Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************/
#import <Foundation/Foundation.h>
@class DataSource;
@protocol DataSourceDelegate<NSObject>
-(void) dataSourceDataAvailable:(DataSource*)dataSource;
-(void) dataSourceErrorOccured:(DataSource*)dataSource;
-(void) dataSourceEof:(DataSource*)dataSource;
@end
@interface DataSource : NSObject
@property (readonly) long long position;
@property (readonly) long long length;
@property (readonly) BOOL hasBytesAvailable;
@property (readwrite, unsafe_unretained) id<DataSourceDelegate> delegate;
-(BOOL) registerForEvents:(NSRunLoop*)runLoop;
-(void) unregisterForEvents;
-(void) close;
-(void) seekToOffset:(long long)offset;
-(int) readIntoBuffer:(UInt8*)buffer withSize:(int)size;
@end

View File

@ -0,0 +1,77 @@
/**********************************************************************************
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the <organization>.
4. Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************/
#import "DataSource.h"
@implementation DataSource
@synthesize delegate;
-(long long) length
{
return 0;
}
-(void) seekToOffset:(long long)offset
{
}
-(int) readIntoBuffer:(UInt8*)buffer withSize:(int)size
{
return -1;
}
-(long long) position
{
return 0;
}
-(BOOL) registerForEvents:(NSRunLoop*)runLoop
{
return NO;
}
-(void) unregisterForEvents
{
}
-(void) close
{
}
-(BOOL) hasBytesAvailable
{
return NO;
}
@end

View File

@ -0,0 +1,51 @@
/**********************************************************************************
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the <organization>.
4. Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************/
#import "CoreFoundationDataSource.h"
@interface HttpDataSource : CoreFoundationDataSource
{
@private
int seekStart;
int relativePosition;
int fileLength;
int discontinuous;
NSDictionary* httpHeaders;
}
@property (readwrite, retain) NSURL* url;
-(id) initWithURL:(NSURL*)url;
@end

View File

@ -0,0 +1,180 @@
/**********************************************************************************
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the <organization>.
4. Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************/
#import "HttpDataSource.h"
@interface HttpDataSource()
-(void) open;
@end
@implementation HttpDataSource
@synthesize url;
-(id) initWithURL:(NSURL*)urlIn
{
if (self = [super init])
{
seekStart = 0;
relativePosition = 0;
fileLength = -1;
self.url = urlIn;
[self open];
}
return self;
}
-(void) dataAvailable
{
if (fileLength < 0)
{
CFTypeRef copyPropertyMessage = CFReadStreamCopyProperty(stream, kCFStreamPropertyHTTPResponseHeader);
httpHeaders = (__bridge NSDictionary*)CFHTTPMessageCopyAllHeaderFields((CFHTTPMessageRef)copyPropertyMessage);
CFRelease(copyPropertyMessage);
if (seekStart == 0)
{
fileLength = [[httpHeaders objectForKey:@"Content-Length"] integerValue];
}
}
[super dataAvailable];
}
-(long long) position
{
return seekStart + relativePosition;
}
-(long long) length
{
return fileLength >= 0 ? fileLength : 0;
}
-(void) seekToOffset:(long long)offset
{
if (eventsRunLoop)
{
[self unregisterForEvents];
}
CFReadStreamClose(stream);
stream = nil;
relativePosition = 0;
seekStart = offset;
[self open];
[self reregisterForEvents];
}
-(int) readIntoBuffer:(UInt8*)buffer withSize:(int)size
{
if (size == 0)
{
return 0;
}
int read = CFReadStreamRead(stream, buffer, size);
if (read < 0)
{
return read;
}
relativePosition += read;
return read;
}
-(void) open
{
CFHTTPMessageRef message = CFHTTPMessageCreateRequest(NULL, (CFStringRef)@"GET", (__bridge CFURLRef)self.url, kCFHTTPVersion1_1);
if (seekStart > 0)
{
CFHTTPMessageSetHeaderFieldValue(message, CFSTR("Range"), (__bridge CFStringRef)[NSString stringWithFormat:@"bytes=%d-", seekStart]);
discontinuous = YES;
}
stream = CFReadStreamCreateForHTTPRequest(NULL, message);
if (!CFReadStreamSetProperty(stream, kCFStreamPropertyHTTPShouldAutoredirect, kCFBooleanTrue))
{
CFRelease(message);
return;
}
// Proxy support
CFDictionaryRef proxySettings = CFNetworkCopySystemProxySettings();
CFReadStreamSetProperty(stream, kCFStreamPropertyHTTPProxy, proxySettings);
CFRelease(proxySettings);
// SSL support
if ([url.scheme caseInsensitiveCompare:@"https"] == NSOrderedSame)
{
NSDictionary* sslSettings = [NSDictionary dictionaryWithObjectsAndKeys:
(NSString*)kCFStreamSocketSecurityLevelNegotiatedSSL, kCFStreamSSLLevel,
[NSNumber numberWithBool:YES], kCFStreamSSLAllowsExpiredCertificates,
[NSNumber numberWithBool:YES], kCFStreamSSLAllowsExpiredRoots,
[NSNumber numberWithBool:YES], kCFStreamSSLAllowsAnyRoot,
[NSNumber numberWithBool:NO], kCFStreamSSLValidatesCertificateChain,
[NSNull null], kCFStreamSSLPeerName,
nil];
CFReadStreamSetProperty(stream, kCFStreamPropertySSLSettings, (__bridge CFTypeRef)sslSettings);
}
// Open
if (!CFReadStreamOpen(stream))
{
CFRelease(stream);
CFRelease(message);
return;
}
CFRelease(message);
}
@end

View File

@ -0,0 +1,48 @@
/**********************************************************************************
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the <organization>.
4. Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************/
#import "CoreFoundationDataSource.h"
@interface LocalFileDataSource : CoreFoundationDataSource
{
@private
long long position;
long long length;
}
@property (readonly, copy) NSString* filePath;
-(id) initWithFilePath:(NSString*)filePath;
@end

View File

@ -0,0 +1,178 @@
/**********************************************************************************
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the <organization>.
4. Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************/
#import "LocalFileDataSource.h"
@interface LocalFileDataSource()
@property (readwrite, copy) NSString* filePath;
-(void) open;
@end
@implementation LocalFileDataSource
@synthesize filePath;
-(id) initWithFilePath:(NSString*)filePathIn
{
if (self = [super init])
{
self.filePath = filePathIn;
[self open];
}
return self;
}
-(void) dealloc
{
[self close];
}
-(void) close
{
if (stream)
{
CFReadStreamClose(stream);
stream = 0;
}
}
-(void) open
{
NSURL* url = [[NSURL alloc] initFileURLWithPath:self.filePath];
BLOG(@"Opening %@", filePath);
if (stream)
{
CFReadStreamClose(stream);
stream = 0;
}
stream = CFReadStreamCreateWithFile(NULL, (__bridge CFURLRef)url);
SInt32 errorCode;
NSNumber* number = (__bridge_transfer NSNumber*)CFURLCreatePropertyFromResource(NULL, (__bridge CFURLRef)url, kCFURLFileLength, &errorCode);
if (number)
{
length = number.longLongValue;
}
CFReadStreamOpen(stream);
}
-(long long) position
{
return position;
}
-(long long) length
{
return length;
}
-(int) readIntoBuffer:(UInt8*)buffer withSize:(int)size
{
int retval = CFReadStreamRead(stream, buffer, size);
if (retval > 0)
{
position += retval;
}
else
{
NSNumber* property = (__bridge_transfer NSNumber*)CFReadStreamCopyProperty(stream, kCFStreamPropertyFileCurrentOffset);
position = property.longLongValue;
}
return retval;
}
-(void) seekToOffset:(long long)offset
{
CFStreamStatus status = kCFStreamStatusClosed;
if (stream != 0)
{
status = CFReadStreamGetStatus(stream);
}
BOOL reopened = NO;
if (status == kCFStreamStatusAtEnd || status == kCFStreamStatusClosed || status == kCFStreamStatusError)
{
reopened = YES;
[self close];
[self open];
[self reregisterForEvents];
}
if (CFReadStreamSetProperty(stream, kCFStreamPropertyFileCurrentOffset, (__bridge CFTypeRef)[NSNumber numberWithLongLong:offset]) != TRUE)
{
position = 0;
BLOG(@"Problem setting stream position");
}
else
{
position = offset;
}
if (!reopened)
{
CFRunLoopPerformBlock(eventsRunLoop.getCFRunLoop, NSRunLoopCommonModes, ^
{
if ([self hasBytesAvailable])
{
[self dataAvailable];
}
});
CFRunLoopWakeUp(eventsRunLoop.getCFRunLoop);
}
}
-(NSString*) description
{
return self->filePath;
}
@end

View File

@ -0,0 +1,32 @@
//
// AudioPlayerView.h
// BlueCucumber-AudioPlayer
//
// Created by Thong Nguyen on 01/06/2012.
// Copyright (c) 2012 Thong Nguyen All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AudioPlayer.h"
@class AudioPlayerView;
@protocol AudioPlayerViewDelegate<NSObject>
-(void) audioPlayerViewPlayFromHTTPSelected:(AudioPlayerView*)audioPlayerView;
-(void) audioPlayerViewPlayFromLocalFileSelected:(AudioPlayerView*)audioPlayerView;
@end
@interface AudioPlayerView : UIView<AudioPlayerDelegate>
{
@private
NSTimer* timer;
UISlider* slider;
UIButton* playButton;
UIButton* playFromHTTPButton;
UIButton* playFromLocalFileButton;
}
@property (readwrite, retain) AudioPlayer* audioPlayer;
@property (readwrite, unsafe_unretained) id<AudioPlayerViewDelegate> delegate;
@end

View File

@ -0,0 +1,181 @@
//
// AudioPlayerView.m
// BlueCucumber-AudioPlayer
//
// Created by Thong Nguyen on 01/06/2012.
// Copyright (c) 2012 Thong Nguyen All rights reserved.
//
#import "AudioPlayerView.h"
@interface AudioPlayerView()
-(void) setupTimer;
-(void) updateControls;
@end
@implementation AudioPlayerView
@synthesize audioPlayer, delegate;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
CGSize size = CGSizeMake(180, 50);
playFromHTTPButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
playFromHTTPButton.frame = CGRectMake((320 - size.width) / 2, 60, size.width, size.height);
[playFromHTTPButton addTarget:self action:@selector(playFromHTTPButtonTouched) forControlEvents:UIControlEventTouchUpInside];
[playFromHTTPButton setTitle:@"Play from HTTP" forState:UIControlStateNormal];
playFromLocalFileButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
playFromLocalFileButton.frame = CGRectMake((320 - size.width) / 2, 120, size.width, size.height);
[playFromLocalFileButton addTarget:self action:@selector(playFromLocalFileButtonTouched) forControlEvents:UIControlEventTouchUpInside];
[playFromLocalFileButton setTitle:@"Play from Local File" forState:UIControlStateNormal];
playButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
playButton.frame = CGRectMake((320 - size.width) / 2, 350, size.width, size.height);
[playButton addTarget:self action:@selector(playButtonPressed) forControlEvents:UIControlEventTouchUpInside];
slider = [[UISlider alloc] initWithFrame:CGRectMake(20, 290, 280, 20)];
slider.continuous = YES;
[slider addTarget:self action:@selector(sliderChanged) forControlEvents:UIControlEventValueChanged];
[self addSubview:slider];
[self addSubview:playButton];
[self addSubview:playFromHTTPButton];
[self addSubview:playFromLocalFileButton];
[self setupTimer];
[self updateControls];
}
return self;
}
-(void) sliderChanged
{
if (!audioPlayer)
{
return;
}
NSLog(@"Slider Changed: %f", slider.value);
[audioPlayer seekToTime:slider.value];
}
-(void) setupTimer
{
timer = [NSTimer timerWithTimeInterval:0.25 target:self selector:@selector(tick) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
}
-(void) tick
{
if (!audioPlayer || audioPlayer.duration == 0)
{
slider.value = 0;
return;
}
slider.minimumValue = 0;
slider.maximumValue = audioPlayer.duration;
slider.value = audioPlayer.progress;
}
-(void) playFromHTTPButtonTouched
{
[self.delegate audioPlayerViewPlayFromHTTPSelected:self];
}
-(void) playFromLocalFileButtonTouched
{
[self.delegate audioPlayerViewPlayFromLocalFileSelected:self];
}
-(void) playButtonPressed
{
if (!audioPlayer)
{
return;
}
if (audioPlayer.state == AudioPlayerStatePaused)
{
[audioPlayer resume];
}
else
{
[audioPlayer pause];
}
}
-(void) updateControls
{
if (audioPlayer == nil)
{
[playButton setTitle:@"Play" forState:UIControlStateNormal];
}
else if (audioPlayer.state == AudioPlayerStatePaused)
{
[playButton setTitle:@"Resume" forState:UIControlStateNormal];
}
else if (audioPlayer.state == AudioPlayerStatePlaying)
{
[playButton setTitle:@"Pause" forState:UIControlStateNormal];
}
else
{
[playButton setTitle:@"Play" forState:UIControlStateNormal];
}
}
-(void) setAudioPlayer:(AudioPlayer*)value
{
if (audioPlayer)
{
audioPlayer.delegate = nil;
}
audioPlayer = value;
audioPlayer.delegate = self;
[self updateControls];
}
-(AudioPlayer*) audioPlayer
{
return audioPlayer;
}
-(void) audioPlayer:(AudioPlayer*)audioPlayer stateChanged:(AudioPlayerState)state
{
[self updateControls];
}
-(void) audioPlayer:(AudioPlayer*)audioPlayer didEncounterError:(AudioPlayerErrorCode)errorCode
{
[self updateControls];
}
-(void) audioPlayer:(AudioPlayer*)audioPlayer didStartPlayingQueueItemId:(NSObject*)queueItemId
{
[self updateControls];
}
-(void) audioPlayer:(AudioPlayer*)audioPlayer didFinishBufferingSourceWithQueueItemId:(NSObject*)queueItemId
{
[self updateControls];
}
-(void) audioPlayer:(AudioPlayer*)audioPlayer didFinishPlayingQueueItemId:(NSObject*)queueItemId withReason:(AudioPlayerStopReason)stopReason andProgress:(double)progress andDuration:(double)duration
{
[self updateControls];
}
@end

View File

@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

18
Audjustable/main.m Normal file
View File

@ -0,0 +1,18 @@
//
// main.m
// Audjustable
//
// Created by Thong Nguyen on 06/06/2012.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}

BIN
Audjustable/sample.m4a Normal file

Binary file not shown.

View File

@ -0,0 +1,5 @@
### Audjustable Audio Streamer
Audjustable is audio streaming class for iOS and OSX. Audjustable uses CoreAudio to decompress and playback audio whilst providing a clean and simple object-oriented API.
Visit the [project homepage](http://tumtumtum.github.com/audjustable)