session-ios/SessionMessagingKit/Utilities/OWSAudioPlayer.h

59 lines
1.7 KiB
C
Raw Permalink Normal View History

//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
2020-11-26 00:37:56 +01:00
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
2017-04-20 17:12:58 +02:00
NS_ASSUME_NONNULL_BEGIN
2021-01-29 01:46:32 +01:00
@class OWSAudioPlayer;
2017-10-10 22:13:54 +02:00
typedef NS_ENUM(NSInteger, AudioPlaybackState) {
AudioPlaybackState_Stopped,
AudioPlaybackState_Playing,
AudioPlaybackState_Paused,
};
@protocol OWSAudioPlayerDelegate
2017-10-10 22:13:54 +02:00
- (AudioPlaybackState)audioPlaybackState;
- (void)setAudioPlaybackState:(AudioPlaybackState)state;
- (void)setAudioProgress:(CGFloat)progress duration:(CGFloat)duration;
2020-11-26 00:37:56 +01:00
- (void)showInvalidAudioFileAlert;
2021-01-29 01:46:32 +01:00
- (void)audioPlayerDidFinishPlaying:(OWSAudioPlayer *)player successfully:(BOOL)flag;
@end
#pragma mark -
2018-10-23 16:40:09 +02:00
typedef NS_ENUM(NSUInteger, OWSAudioBehavior) {
OWSAudioBehavior_Unknown,
OWSAudioBehavior_Playback,
OWSAudioBehavior_AudioMessagePlayback,
OWSAudioBehavior_PlayAndRecord,
OWSAudioBehavior_Call,
};
2018-02-23 21:44:46 +01:00
@interface OWSAudioPlayer : NSObject
@property (nonatomic, weak) id<OWSAudioPlayerDelegate> delegate;
2021-01-29 01:46:32 +01:00
// This property can be used to associate instances of the player with view or model objects.
@property (nonatomic, weak) id owner;
2018-02-23 21:44:46 +01:00
@property (nonatomic) BOOL isLooping;
2021-01-29 01:46:32 +01:00
@property (nonatomic) BOOL isPlaying;
@property (nonatomic) float playbackRate;
@property (nonatomic) NSTimeInterval duration;
2018-02-23 21:44:46 +01:00
2018-10-23 16:40:09 +02:00
- (instancetype)initWithMediaUrl:(NSURL *)mediaUrl audioBehavior:(OWSAudioBehavior)audioBehavior;
- (instancetype)initWithMediaUrl:(NSURL *)mediaUrl audioBehavior:(OWSAudioBehavior)audioBehavior delegate:(nullable id<OWSAudioPlayerDelegate>)delegate;
2018-10-23 16:40:09 +02:00
- (void)play;
2020-10-19 02:21:04 +02:00
- (void)setCurrentTime:(NSTimeInterval)currentTime;
- (void)pause;
- (void)stop;
2018-10-23 16:40:09 +02:00
- (void)togglePlayState;
@end
2017-04-20 17:12:58 +02:00
NS_ASSUME_NONNULL_END