static public void StopMusic() { if (!m_bMusicInited) { return; } if (!m_bMusicInited || null == m_MusicPlayer || null == m_MusicPlayer.SoundPlayer) { return; } if (m_MusicPlayer.SoundPlayer.isPlaying) { m_MusicPlayer.SoundPlayer.Stop(); } //if( Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer ) //{ // if( null != m_MusicPlayer.SoundObj ) // { // GameObject.DestroyImmediate( m_MusicPlayer.SoundObj , true ); //} //} MusicAssetMgr.DeleteAsset(m_MusicPlayer.szName, true); m_MusicPlayer.SoundPlayer.clip = null; m_MusicPlayer.SoundObj = null; m_MusicPlayer.szName = ""; }
static private void PlayMusic(MUSIC_ID id, bool bLoop) { if (PlayerPrefs.GetInt("settingMusic") == 1) { return; } if (!m_bMusicInited) { InitPlayMusic(); } string szName = GlobalInstanceFunction.Instance.GetAssetsName((int)id, AssetLoader.EAssetType.ASSET_MUSIC); if (!GlobalInstanceFunction.Instance.IsValidName(szName)) { return; } if (szName == m_MusicPlayer.szName && m_MusicPlayer.SoundObj != null && m_MusicPlayer.SoundPlayer != null) { m_MusicPlayer.SoundPlayer.volume = SOUNDVOLME; m_MusicPlayer.SoundPlayer.loop = bLoop; m_MusicPlayer.SoundPlayer.Play(); return; } MusicAssetMgr.LoadAsset(szName, new ParamData(bLoop)); }
static public void SetStopMusic() { PlayerPrefs.SetInt("settingMusic", 1); settingDirty = true; if (!m_bMusicInited || null == m_MusicPlayer || null == m_MusicPlayer.SoundPlayer) { return; } m_MusicPlayer.SoundPlayer.Stop(); /*if( Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer ) * { * if( null != m_MusicPlayer.SoundObj ) * { * GameObject.DestroyImmediate( m_MusicPlayer.SoundObj , true ); * } * } */ MusicAssetMgr.DeleteAsset(m_MusicPlayer.szName, true); m_MusicPlayer.SoundPlayer.clip = null; m_MusicPlayer.SoundObj = null; m_MusicPlayer.szName = ""; }
static public void PlayMusicCallBack(AssetBundle AssetData, ParamData paramData) { if (null == AssetData || null == AssetData.mainAsset) { MusicAssetMgr.DeleteAsset(AssetData, true); return; } //Delete Asset and Play new Music if (null != paramData) { if (null != m_MusicPlayer.SoundPlayer) { StopMusic(); AudioClip Source = AssetData.mainAsset as AudioClip; m_MusicPlayer.SoundObj = Source; m_MusicPlayer.SoundPlayer.clip = Source; m_MusicPlayer.SoundPlayer.volume = SOUNDVOLME; m_MusicPlayer.SoundPlayer.loop = paramData.bParam; m_MusicPlayer.szName = paramData.szAssetName; m_MusicPlayer.SoundPlayer.Play(); } } }