session-ios/SignalMessaging/attachments/OWSAudioAttachmentPlayer.h
Michael Kirk c646f76335 Garther audio concerns, clean up session when done
- sync speakerphone state manipulated from system call screen
  - Revert audio session after call failure, ensures media plays out of
    speaker after placing a failing call.
  - Replace notification with delegate pattern since we're already using
    delegate pattern here.
- Fixes voiceover accessibility after voice memo
- Avoid audio blip after pressing hangup
- Rename CallAudioSession -> OWSAudioSession
  Going to start using it for other non-call things since we want to
  gather all our audio session concerns.
- Resume background audio when done playing video
  - Extract OWSVideoPlayer which ensures audio is in proper state before
    playback
  - Move recording session logic to shared OWSAudioSession
  - Deactivate audio session when complete

// FREEBIE
2018-02-06 18:45:51 -08:00

45 lines
1 KiB
Objective-C

//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@class TSVideoAttachmentAdapter;
typedef NS_ENUM(NSInteger, AudioPlaybackState) {
AudioPlaybackState_Stopped,
AudioPlaybackState_Playing,
AudioPlaybackState_Paused,
};
@protocol OWSAudioAttachmentPlayerDelegate <NSObject>
- (AudioPlaybackState)audioPlaybackState;
- (void)setAudioPlaybackState:(AudioPlaybackState)state;
- (void)setAudioProgress:(CGFloat)progress duration:(CGFloat)duration;
@end
#pragma mark -
@interface OWSAudioAttachmentPlayer : NSObject
@property (nonatomic, readonly, weak) id<OWSAudioAttachmentPlayerDelegate> delegate;
// This property can be used to associate instances of the player with view
// or model objects.
@property (nonatomic, weak) id owner;
// An generic initializer.
- (instancetype)initWithMediaUrl:(NSURL *)mediaUrl delegate:(id<OWSAudioAttachmentPlayerDelegate>)delegate;
- (void)play;
- (void)pause;
- (void)stop;
- (void)togglePlayState;
@end
NS_ASSUME_NONNULL_END