-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWKAudioStreamer.h
66 lines (48 loc) · 1.84 KB
/
WKAudioStreamer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// WKAudioStreamer.h
// WKAudioStreamer
//
// Created by Chenguang Wang on 11/16/12.
// Copyright (c) 2012 Chenguang Wang. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol WKAudioStreamerDelegate;
@interface WKAudioStreamer : NSObject
// streaming will not start right after the streamer is created.
// the user would have to call startStreaming by hand.
+ (id)streamerWithURLString:(NSString *)url
delegate:(id<WKAudioStreamerDelegate>)delegate;
// return YES on success.
- (BOOL)play;
- (BOOL)pause;
// if seek returns YES, it means later data received by the delegate will not be continuous
// with the previous ones -- which means you cannot save them onto your disk as a single file anymore.
- (BOOL)seek:(double)targetTime;
- (double)duration;
- (int)fileSize; // return 0 if file size is still unknown.
// startStreaming will always start streaming from the beginning of file.
- (void)startStreaming;
- (void)pauseStreaming;
- (void)restartStreaming;
- (NSString *)requestedURL;
- (BOOL)streamingFinished;
- (BOOL)isPlayerBlocking;
@end
////////////////////////////////////////////////
///////////////// the delegate /////////////////
////////////////////////////////////////////////
@protocol WKAudioStreamerDelegate <NSObject>
@required
// - (void)onPlayerReady:(WKAudioStreamer *)streamer;
- (void)onStreamingFinished:(WKAudioStreamer *)streamer;
- (void)onPlayingFinished:(WKAudioStreamer *)streamer;
- (void)onDataReceived:(WKAudioStreamer *)streamer
data:(NSData *)newData;
@optional
- (void)onErrorOccured:(WKAudioStreamer *)streamer
error:(NSError *)error;
- (void)onPlayerPosChanged:(WKAudioStreamer *)streamer
pos:(double)pos;
- (void)onPlayerBlocked:(WKAudioStreamer *)streamer;
- (void)onPlayerBlockingEnded:(WKAudioStreamer *)streamer;
@end