//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // PUBLIC FUNCTION //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // @Brief : Play // @Param : pClip => Audio clip // : bIsLoop => Is loop mode public void Play(AudioClip pClip, bool bIsLoop) { m_pAudioSource.clip = pClip; m_pAudioSource.loop = bIsLoop; m_pAudioSource.Play(); m_eStatus = ePLAYBACK_STATUS.PLAYING; }
// @Brief : Update void Update() { if (!m_pAudioSource.isPlaying) { if (m_eStatus == ePLAYBACK_STATUS.PLAYING) { m_eStatus = ePLAYBACK_STATUS.STOP; } } }
// @Brief : Stop public void Stop() { m_pAudioSource.Stop(); m_eStatus = ePLAYBACK_STATUS.STOP; }
// @Breif : Un pause public void UnPause() { m_pAudioSource.Pause(); m_eStatus = ePLAYBACK_STATUS.PLAYING; }
// @Breif : Pause public void Pause() { m_pAudioSource.Pause(); m_eStatus = ePLAYBACK_STATUS.PAUSE; }
private ePLAYBACK_STATUS m_eStatus = ePLAYBACK_STATUS.PREPARE; // playback status //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // UNITY FUNCTION //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // @Breif : Awake void Awake() { m_pAudioSource = GetComponent <AudioSource>(); m_eStatus = ePLAYBACK_STATUS.PREPARE; }