Adding ViroKit. Needs AWSCore :(

This commit is contained in:
John Lyon-Smith
2018-03-27 17:46:15 -07:00
parent 2ab15e7dc1
commit 02e06dface
844 changed files with 86921 additions and 21 deletions

View File

@@ -0,0 +1,89 @@
//
// VROAudioPlayeriOS.h
// ViroRenderer
//
// Created by Raj Advani on 11/6/16.
// Copyright © 2016 Viro Media. All rights reserved.
//
#ifndef VROAudioPlayeriOS_h
#define VROAudioPlayeriOS_h
#include "VROAudioPlayer.h"
#include "VROSoundDataDelegate.h"
#include "VROSoundData.h"
#include <AVFoundation/AVFoundation.h>
/*
Simple object that wraps a VROSoundDelegateInternal object and acts as a delegate for the AVAudioPlayer
*/
@interface VROAudioPlayerDelegate : NSObject <AVAudioPlayerDelegate>
- (id)initWithSoundDelegate:(std::shared_ptr<VROSoundDelegateInternal>)soundDelegate;
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag;
@end
class VROAudioPlayeriOS : public VROAudioPlayer, public VROSoundDataDelegate, public std::enable_shared_from_this<VROAudioPlayeriOS> {
public:
VROAudioPlayeriOS(std::string url, bool isLocalUrl);
VROAudioPlayeriOS(std::shared_ptr<VROData> data);
VROAudioPlayeriOS(std::shared_ptr<VROSoundData> data);
virtual ~VROAudioPlayeriOS();
/*
Must be invoke after construction, after setting the delegate.
*/
void setup();
void setDelegate(std::shared_ptr<VROSoundDelegateInternal> delegate);
void setLoop(bool loop);
void play();
void pause();
void setVolume(float volume);
void setMuted(bool muted);
void seekToTime(float seconds);
#pragma mark VROSoundDataDelegate Implementation
void dataIsReady();
void dataError(std::string error);
private:
/*
Underlying iOS audio player. The delegate is only kept here so that
it's retained.
*/
AVAudioPlayer *_player;
VROAudioPlayerDelegate *_audioDelegate;
/*
Generic settings.
*/
float _playVolume;
bool _muted;
bool _paused;
bool _loop;
bool _isLocal;
/*
Source audio.
*/
std::string _url;
std::shared_ptr<VROSoundData> _data;
/*
Update the underlying iOS player with the various properties set on this
player (e.g. muted, loop, volume, etc.)
*/
void updatePlayerProperties();
void doFadeThenPause();
void doFadeThenStop();
};
#endif /* VROAudioPlayeriOS_h */