240 lines
5.2 KiB
C#
240 lines
5.2 KiB
C#
using System;
|
|
using Crosstales.Radio.Model;
|
|
using Crosstales.Radio.Model.Enum;
|
|
using Crosstales.Radio.Util;
|
|
using UnityEngine;
|
|
|
|
namespace Crosstales.Radio
|
|
{
|
|
public abstract class BasePlayer : MonoBehaviour
|
|
{
|
|
protected PlaybackStart _playbackStart;
|
|
|
|
protected PlaybackEnd _playbackEnd;
|
|
|
|
protected BufferingStart _bufferingStart;
|
|
|
|
protected BufferingEnd _bufferingEnd;
|
|
|
|
protected BufferingProgressUpdate _bufferingProgressUpdate;
|
|
|
|
protected AudioStart _audioStart;
|
|
|
|
protected AudioEnd _audioEnd;
|
|
|
|
protected AudioPlayTimeUpdate _audioPlayTimeUpdate;
|
|
|
|
protected RecordChange _recordChange;
|
|
|
|
protected RecordPlayTimeUpdate _recordPlayTimeUpdate;
|
|
|
|
protected NextRecordChange _nextRecordChange;
|
|
|
|
protected NextRecordDelayUpdate _nextRecordDelayUpdate;
|
|
|
|
protected ErrorInfo _errorInfo;
|
|
|
|
public abstract RadioStation RadioStation { get; set; }
|
|
|
|
public abstract AudioSource Source { get; protected set; }
|
|
|
|
public abstract AudioCodec Codec { get; protected set; }
|
|
|
|
public abstract float PlayTime { get; protected set; }
|
|
|
|
public abstract float BufferProgress { get; protected set; }
|
|
|
|
public abstract bool isPlayback { get; }
|
|
|
|
public abstract bool isAudioPlaying { get; }
|
|
|
|
public abstract bool isBuffering { get; }
|
|
|
|
public abstract float RecordPlayTime { get; protected set; }
|
|
|
|
public abstract RecordInfo RecordInfo { get; }
|
|
|
|
public abstract bool isLegacyMode { get; set; }
|
|
|
|
public abstract bool isCaptureDataStream { get; set; }
|
|
|
|
public abstract RecordInfo NextRecordInfo { get; }
|
|
|
|
public abstract float NextRecordDelay { get; }
|
|
|
|
public abstract long CurrentBufferSize { get; }
|
|
|
|
public abstract long CurrentDownloadSpeed { get; }
|
|
|
|
public abstract MemoryCacheStream DataStream { get; protected set; }
|
|
|
|
public abstract int Channels { get; protected set; }
|
|
|
|
public abstract int SampleRate { get; protected set; }
|
|
|
|
public event PlaybackStart OnPlaybackStart
|
|
{
|
|
add
|
|
{
|
|
_playbackStart = (PlaybackStart)Delegate.Combine(_playbackStart, value);
|
|
}
|
|
remove
|
|
{
|
|
_playbackStart = (PlaybackStart)Delegate.Remove(_playbackStart, value);
|
|
}
|
|
}
|
|
|
|
public event PlaybackEnd OnPlaybackEnd
|
|
{
|
|
add
|
|
{
|
|
_playbackEnd = (PlaybackEnd)Delegate.Combine(_playbackEnd, value);
|
|
}
|
|
remove
|
|
{
|
|
_playbackEnd = (PlaybackEnd)Delegate.Remove(_playbackEnd, value);
|
|
}
|
|
}
|
|
|
|
public event BufferingStart OnBufferingStart
|
|
{
|
|
add
|
|
{
|
|
_bufferingStart = (BufferingStart)Delegate.Combine(_bufferingStart, value);
|
|
}
|
|
remove
|
|
{
|
|
_bufferingStart = (BufferingStart)Delegate.Remove(_bufferingStart, value);
|
|
}
|
|
}
|
|
|
|
public event BufferingEnd OnBufferingEnd
|
|
{
|
|
add
|
|
{
|
|
_bufferingEnd = (BufferingEnd)Delegate.Combine(_bufferingEnd, value);
|
|
}
|
|
remove
|
|
{
|
|
_bufferingEnd = (BufferingEnd)Delegate.Remove(_bufferingEnd, value);
|
|
}
|
|
}
|
|
|
|
public event BufferingProgressUpdate OnBufferingProgressUpdate
|
|
{
|
|
add
|
|
{
|
|
_bufferingProgressUpdate = (BufferingProgressUpdate)Delegate.Combine(_bufferingProgressUpdate, value);
|
|
}
|
|
remove
|
|
{
|
|
_bufferingProgressUpdate = (BufferingProgressUpdate)Delegate.Remove(_bufferingProgressUpdate, value);
|
|
}
|
|
}
|
|
|
|
public event AudioStart OnAudioStart
|
|
{
|
|
add
|
|
{
|
|
_audioStart = (AudioStart)Delegate.Combine(_audioStart, value);
|
|
}
|
|
remove
|
|
{
|
|
_audioStart = (AudioStart)Delegate.Remove(_audioStart, value);
|
|
}
|
|
}
|
|
|
|
public event AudioEnd OnAudioEnd
|
|
{
|
|
add
|
|
{
|
|
_audioEnd = (AudioEnd)Delegate.Combine(_audioEnd, value);
|
|
}
|
|
remove
|
|
{
|
|
_audioEnd = (AudioEnd)Delegate.Remove(_audioEnd, value);
|
|
}
|
|
}
|
|
|
|
public event AudioPlayTimeUpdate OnAudioPlayTimeUpdate
|
|
{
|
|
add
|
|
{
|
|
_audioPlayTimeUpdate = (AudioPlayTimeUpdate)Delegate.Combine(_audioPlayTimeUpdate, value);
|
|
}
|
|
remove
|
|
{
|
|
_audioPlayTimeUpdate = (AudioPlayTimeUpdate)Delegate.Remove(_audioPlayTimeUpdate, value);
|
|
}
|
|
}
|
|
|
|
public event RecordChange OnRecordChange
|
|
{
|
|
add
|
|
{
|
|
_recordChange = (RecordChange)Delegate.Combine(_recordChange, value);
|
|
}
|
|
remove
|
|
{
|
|
_recordChange = (RecordChange)Delegate.Remove(_recordChange, value);
|
|
}
|
|
}
|
|
|
|
public event RecordPlayTimeUpdate OnRecordPlayTimeUpdate
|
|
{
|
|
add
|
|
{
|
|
_recordPlayTimeUpdate = (RecordPlayTimeUpdate)Delegate.Combine(_recordPlayTimeUpdate, value);
|
|
}
|
|
remove
|
|
{
|
|
_recordPlayTimeUpdate = (RecordPlayTimeUpdate)Delegate.Remove(_recordPlayTimeUpdate, value);
|
|
}
|
|
}
|
|
|
|
public event NextRecordChange OnNextRecordChange
|
|
{
|
|
add
|
|
{
|
|
_nextRecordChange = (NextRecordChange)Delegate.Combine(_nextRecordChange, value);
|
|
}
|
|
remove
|
|
{
|
|
_nextRecordChange = (NextRecordChange)Delegate.Remove(_nextRecordChange, value);
|
|
}
|
|
}
|
|
|
|
public event NextRecordDelayUpdate OnNextRecordDelayUpdate
|
|
{
|
|
add
|
|
{
|
|
_nextRecordDelayUpdate = (NextRecordDelayUpdate)Delegate.Combine(_nextRecordDelayUpdate, value);
|
|
}
|
|
remove
|
|
{
|
|
_nextRecordDelayUpdate = (NextRecordDelayUpdate)Delegate.Remove(_nextRecordDelayUpdate, value);
|
|
}
|
|
}
|
|
|
|
public event ErrorInfo OnErrorInfo
|
|
{
|
|
add
|
|
{
|
|
_errorInfo = (ErrorInfo)Delegate.Combine(_errorInfo, value);
|
|
}
|
|
remove
|
|
{
|
|
_errorInfo = (ErrorInfo)Delegate.Remove(_errorInfo, value);
|
|
}
|
|
}
|
|
|
|
public abstract void Play();
|
|
|
|
public abstract void Stop();
|
|
|
|
public abstract void Silence();
|
|
|
|
public abstract void Restart(float invokeDelay = 0.4f);
|
|
}
|
|
}
|