Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions ExampleApp/ExampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
77DFD7FA1940171300B661F1 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77DFD7F91940171300B661F1 /* MediaPlayer.framework */; };
A1115935188D686000641365 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A1115934188D686000641365 /* Foundation.framework */; };
A1115937188D686000641365 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A1115936188D686000641365 /* CoreGraphics.framework */; };
A1115939188D686000641365 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A1115938188D686000641365 /* UIKit.framework */; };
Expand All @@ -30,6 +31,34 @@
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
43CC18FC1945FBB3007F8ED3 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 77DFD7E919400FF600B661F1 /* StreamingKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = A1E7C4C8188D57F50010896F;
remoteInfo = StreamingKit;
};
43CC18FE1945FBB3007F8ED3 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 77DFD7E919400FF600B661F1 /* StreamingKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = A1E7C4D8188D57F60010896F;
remoteInfo = StreamingKitTests;
};
43CC19001945FBB3007F8ED3 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 77DFD7E919400FF600B661F1 /* StreamingKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = A1A49969189E744400E2A2E2;
remoteInfo = StreamingKitMac;
};
43CC19021945FBB3007F8ED3 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 77DFD7E919400FF600B661F1 /* StreamingKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = A1A4997A189E744500E2A2E2;
remoteInfo = StreamingKitMacTests;
};
A1115951188D686000641365 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A1115929188D686000641365 /* Project object */;
Expand All @@ -40,6 +69,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
77DFD7E919400FF600B661F1 /* StreamingKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = StreamingKit.xcodeproj; path = ../StreamingKit/StreamingKit.xcodeproj; sourceTree = "<group>"; };
77DFD7F91940171300B661F1 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; };
A1115931188D686000641365 /* ExampleApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExampleApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
A1115934188D686000641365 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
A1115936188D686000641365 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -74,6 +105,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
77DFD7FA1940171300B661F1 /* MediaPlayer.framework in Frameworks */,
A17FFB6918A002E400BAA7FF /* AVFoundation.framework in Frameworks */,
A17FFB6318A0028300BAA7FF /* AudioToolbox.framework in Frameworks */,
A1EBEE64188DE34500681B04 /* SystemConfiguration.framework in Frameworks */,
Expand All @@ -97,9 +129,21 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
43CC18F61945FBB3007F8ED3 /* Products */ = {
isa = PBXGroup;
children = (
43CC18FD1945FBB3007F8ED3 /* libStreamingKit.a */,
43CC18FF1945FBB3007F8ED3 /* StreamingKitTests.xctest */,
43CC19011945FBB3007F8ED3 /* libStreamingKitMac.a */,
43CC19031945FBB3007F8ED3 /* StreamingKitMacTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
A1115928188D686000641365 = {
isa = PBXGroup;
children = (
77DFD7E919400FF600B661F1 /* StreamingKit.xcodeproj */,
A111593A188D686000641365 /* ExampleApp */,
A1115953188D686000641365 /* ExampleAppTests */,
A1115933188D686000641365 /* Frameworks */,
Expand All @@ -119,6 +163,7 @@
A1115933188D686000641365 /* Frameworks */ = {
isa = PBXGroup;
children = (
77DFD7F91940171300B661F1 /* MediaPlayer.framework */,
A17FFB6218A0028300BAA7FF /* AudioToolbox.framework */,
A1F5E491189EB3F20070B03F /* AVFoundation.framework */,
A1F5E48F189EB3CB0070B03F /* AudioUnit.framework */,
Expand Down Expand Up @@ -248,6 +293,12 @@
mainGroup = A1115928188D686000641365;
productRefGroup = A1115932188D686000641365 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 43CC18F61945FBB3007F8ED3 /* Products */;
ProjectRef = 77DFD7E919400FF600B661F1 /* StreamingKit.xcodeproj */;
},
);
projectRoot = "";
targets = (
A1115930188D686000641365 /* ExampleApp */,
Expand All @@ -256,6 +307,37 @@
};
/* End PBXProject section */

/* Begin PBXReferenceProxy section */
43CC18FD1945FBB3007F8ED3 /* libStreamingKit.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libStreamingKit.a;
remoteRef = 43CC18FC1945FBB3007F8ED3 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
43CC18FF1945FBB3007F8ED3 /* StreamingKitTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = StreamingKitTests.xctest;
remoteRef = 43CC18FE1945FBB3007F8ED3 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
43CC19011945FBB3007F8ED3 /* libStreamingKitMac.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libStreamingKitMac.a;
remoteRef = 43CC19001945FBB3007F8ED3 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
43CC19031945FBB3007F8ED3 /* StreamingKitMacTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = StreamingKitMacTests.xctest;
remoteRef = 43CC19021945FBB3007F8ED3 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */

/* Begin PBXResourcesBuildPhase section */
A111592F188D686000641365 /* Resources */ = {
isa = PBXResourcesBuildPhase;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure you should have added this...

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>22C746FF-1363-4588-AEC8-A3B9E903D0B7</string>
<key>IDESourceControlProjectName</key>
<string>ExampleApp</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>88A9FD5F-A3FE-408E-97E8-82A7561B7E01</key>
<string>https://github.com/ghfghfg23/StreamingKit.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>ExampleApp/ExampleApp.xcodeproj/project.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>88A9FD5F-A3FE-408E-97E8-82A7561B7E01</key>
<string>../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/ghfghfg23/StreamingKit.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>88A9FD5F-A3FE-408E-97E8-82A7561B7E01</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>88A9FD5F-A3FE-408E-97E8-82A7561B7E01</string>
<key>IDESourceControlWCCName</key>
<string>StreamingKit</string>
</dict>
</array>
</dict>
</plist>
24 changes: 24 additions & 0 deletions ExampleApp/ExampleApp/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import "STKAutoRecoveringHTTPDataSource.h"
#import "SampleQueueId.h"
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>

@interface AppDelegate()
{
Expand Down Expand Up @@ -96,4 +97,27 @@ -(void) audioPlayerViewQueuePcmWaveFileSelected:(AudioPlayerView*)audioPlayerVie
[audioPlayer queueDataSource:dataSource withQueueItemId:[[SampleQueueId alloc] initWithUrl:url andCount:0]];
}

-(void) audioPlayerViewPlayFromiTunesLibrarySelected:(AudioPlayerView*)audioPlayerView
{
NSArray *alliTunesTracks = [[MPMediaQuery songsQuery] items];
if (alliTunesTracks.count < 1) {
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"iTunes library empty" message:@"load track and try again" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[av show];
return;
}
MPMediaItem *randomItem = nil;
while (!randomItem) {
NSUInteger randomIndex = arc4random_uniform(alliTunesTracks.count-1);
randomItem = [alliTunesTracks objectAtIndex:randomIndex];
if ([[randomItem valueForProperty:MPMediaItemPropertyIsCloudItem] boolValue]) {
randomItem = nil;
continue;
}
}
NSURL *url = [randomItem valueForProperty:MPMediaItemPropertyAssetURL];
STKDataSource *dataSource = [STKAudioPlayer dataSourceFromURL:url];
[audioPlayer setDataSource:dataSource withQueueItemId:[[SampleQueueId alloc] initWithUrl:url andCount:0]];
}


@end
2 changes: 2 additions & 0 deletions ExampleApp/ExampleApp/AudioPlayerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
-(void) audioPlayerViewQueueShortFileSelected:(AudioPlayerView*)audioPlayerView;
-(void) audioPlayerViewPlayFromLocalFileSelected:(AudioPlayerView*)audioPlayerView;
-(void) audioPlayerViewQueuePcmWaveFileSelected:(AudioPlayerView*)audioPlayerView;
-(void) audioPlayerViewPlayFromiTunesLibrarySelected:(AudioPlayerView*)audioPlayerView;
@end

@interface AudioPlayerView : UIView<STKAudioPlayerDelegate>
Expand All @@ -55,6 +56,7 @@
UISwitch* repeatSwitch;
UIButton* muteButton;
UIButton* playButton;
UIButton* playFromiTunesLibrary;
UIButton* stopButton;
UIButton* playFromHTTPButton;
UIButton* queueShortFileButton;
Expand Down
12 changes: 11 additions & 1 deletion ExampleApp/ExampleApp/AudioPlayerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,15 @@ - (id)initWithFrame:(CGRect)frame andAudioPlayer:(STKAudioPlayer*)audioPlayerIn
[playFromHTTPButton setTitle:@"Play from HTTP" forState:UIControlStateNormal];

playFromLocalFileButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
playFromLocalFileButton.frame = CGRectMake((320 - size.width) / 2, frame.size.height * 0.10 + 50, size.width, size.height);
playFromLocalFileButton.frame = CGRectMake((320 - size.width * 1.4) / 2, frame.size.height * 0.10 + 50, size.width * 0.7, size.height);
[playFromLocalFileButton addTarget:self action:@selector(playFromLocalFileButtonTouched) forControlEvents:UIControlEventTouchUpInside];
[playFromLocalFileButton setTitle:@"Play from Local File" forState:UIControlStateNormal];

playFromiTunesLibrary = [UIButton buttonWithType:UIButtonTypeRoundedRect];
playFromiTunesLibrary.frame = CGRectMake(playFromLocalFileButton.frame.origin.x + playFromLocalFileButton.frame.size.width, playFromLocalFileButton.frame.origin.y, size.width * 0.7f, size.height);
[playFromiTunesLibrary addTarget:self action:@selector(playFromiTunesLibraryTouched) forControlEvents:UIControlEventTouchUpInside];
[playFromiTunesLibrary setTitle:@"from iTunes Lib" forState:UIControlStateNormal];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad formatting


queueShortFileButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
queueShortFileButton.frame = CGRectMake((320 - size.width) / 2, frame.size.height * 0.10 + 100, size.width, size.height);
[queueShortFileButton addTarget:self action:@selector(queueShortFileButtonTouched) forControlEvents:UIControlEventTouchUpInside];
Expand Down Expand Up @@ -122,6 +127,7 @@ - (id)initWithFrame:(CGRect)frame andAudioPlayer:(STKAudioPlayer*)audioPlayerIn
[self addSubview:playButton];
[self addSubview:playFromHTTPButton];
[self addSubview:playFromLocalFileButton];
[self addSubview:playFromiTunesLibrary];
[self addSubview:queueShortFileButton];
[self addSubview:queuePcmWaveFileFromHTTPButton];
[self addSubview:repeatSwitch];
Expand Down Expand Up @@ -208,6 +214,10 @@ -(void) playFromLocalFileButtonTouched
[self.delegate audioPlayerViewPlayFromLocalFileSelected:self];
}

-(void) playFromiTunesLibraryTouched
{
[self.delegate audioPlayerViewPlayFromiTunesLibrarySelected:self];
}
-(void) queueShortFileButtonTouched
{
[self.delegate audioPlayerViewQueueShortFileSelected:self];
Expand Down
12 changes: 12 additions & 0 deletions StreamingKit/StreamingKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
43CC19061945FBF4007F8ED3 /* STKMediaLibraryFileDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 43CC19051945FBF4007F8ED3 /* STKMediaLibraryFileDataSource.m */; };
77DFD7FD1940200300B661F1 /* STKMediaLibraryFileLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 77DFD7FC1940200300B661F1 /* STKMediaLibraryFileLoader.m */; };
A1A4996B189E744400E2A2E2 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A1A4996A189E744400E2A2E2 /* Cocoa.framework */; };
A1A49975189E744500E2A2E2 /* StreamingKitMac.m in Sources */ = {isa = PBXBuildFile; fileRef = A1A49974189E744500E2A2E2 /* StreamingKitMac.m */; };
A1A4997B189E744500E2A2E2 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A1E7C4D9188D57F60010896F /* XCTest.framework */; };
Expand Down Expand Up @@ -83,6 +85,10 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
43CC19041945FBF4007F8ED3 /* STKMediaLibraryFileDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = STKMediaLibraryFileDataSource.h; sourceTree = "<group>"; };
43CC19051945FBF4007F8ED3 /* STKMediaLibraryFileDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STKMediaLibraryFileDataSource.m; sourceTree = "<group>"; };
77DFD7FB1940200300B661F1 /* STKMediaLibraryFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = STKMediaLibraryFileLoader.h; sourceTree = "<group>"; };
77DFD7FC1940200300B661F1 /* STKMediaLibraryFileLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STKMediaLibraryFileLoader.m; sourceTree = "<group>"; };
A1A49969189E744400E2A2E2 /* libStreamingKitMac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libStreamingKitMac.a; sourceTree = BUILT_PRODUCTS_DIR; };
A1A4996A189E744400E2A2E2 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; };
A1A4996D189E744500E2A2E2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -276,6 +282,10 @@
A1E7C4FC188D5E550010896F /* STKHTTPDataSource.m */,
A1E7C4FD188D5E550010896F /* STKLocalFileDataSource.h */,
A1E7C4FE188D5E550010896F /* STKLocalFileDataSource.m */,
77DFD7FB1940200300B661F1 /* STKMediaLibraryFileLoader.h */,
77DFD7FC1940200300B661F1 /* STKMediaLibraryFileLoader.m */,
43CC19041945FBF4007F8ED3 /* STKMediaLibraryFileDataSource.h */,
43CC19051945FBF4007F8ED3 /* STKMediaLibraryFileDataSource.m */,
A1BF65D0189A6582004DD08C /* STKQueueEntry.h */,
A1BF65D1189A6582004DD08C /* STKQueueEntry.m */,
A1BF65D3189A65C6004DD08C /* NSMutableArray+STKAudioPlayer.h */,
Expand Down Expand Up @@ -497,13 +507,15 @@
buildActionMask = 2147483647;
files = (
A1E7C501188D5E550010896F /* STKCoreFoundationDataSource.m in Sources */,
77DFD7FD1940200300B661F1 /* STKMediaLibraryFileLoader.m in Sources */,
A1E7C4FF188D5E550010896F /* STKAudioPlayer.m in Sources */,
A1E7C505188D5E550010896F /* STKLocalFileDataSource.m in Sources */,
A1BF65D2189A6582004DD08C /* STKQueueEntry.m in Sources */,
A1E7C504188D5E550010896F /* STKHTTPDataSource.m in Sources */,
A1E7C503188D5E550010896F /* STKDataSourceWrapper.m in Sources */,
A1E7C502188D5E550010896F /* STKDataSource.m in Sources */,
A1BF65D5189A65C6004DD08C /* NSMutableArray+STKAudioPlayer.m in Sources */,
43CC19061945FBF4007F8ED3 /* STKMediaLibraryFileDataSource.m in Sources */,
A1E7C500188D5E550010896F /* STKAutoRecoveringHTTPDataSource.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
4 changes: 4 additions & 0 deletions StreamingKit/StreamingKit/STKAudioPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ This product includes software developed by Thong Nguyen (tumtumtum@gmail.com)
#import "STKHTTPDataSource.h"
#import "STKAutoRecoveringHTTPDataSource.h"
#import "STKLocalFileDataSource.h"
#import "STKMediaLibraryFileDataSource.h"
#import "STKQueueEntry.h"
#import "NSMutableArray+STKAudioPlayer.h"
#import "libkern/OSAtomic.h"
Expand Down Expand Up @@ -625,6 +626,9 @@ +(STKDataSource*) dataSourceFromURL:(NSURL*)url
{
retval = [[STKAutoRecoveringHTTPDataSource alloc] initWithHTTPDataSource:[[STKHTTPDataSource alloc] initWithURL:url]];
}
else if ([url.scheme caseInsensitiveCompare:@"ipod-library"] == NSOrderedSame) {
retval = [[STKMediaLibraryFileDataSource alloc] initWithMediaURL:url];
}

return retval;
}
Expand Down
14 changes: 14 additions & 0 deletions StreamingKit/StreamingKit/STKMediaLibraryFileDataSource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// STKMediaLibraryFileDataSource.h
// StreamingKit
//
// Created by Andrey Ryabov on 09.06.14.
// Copyright (c) 2014 Thong Nguyen. All rights reserved.
//

#import "STKLocalFileDataSource.h"

@interface STKMediaLibraryFileDataSource : STKCoreFoundationDataSource
@property (nonatomic, strong) NSURL *mediaURL;
- (instancetype)initWithMediaURL:(NSURL *)url;
@end
Loading