static void Trim() { // WP8 only supports one channel :( while (AudioHandles.Count > 0) { AudioHandle oldestHandle = null; DateTime oldestTime = DateTime.Now; for (int i = 0; i < AudioHandles.Count; ++i) { AudioHandle audioHandle = AudioHandles[i]; if (audioHandle.mediaElement == null) { oldestHandle = audioHandle; break; } else if (!audioHandle.playing) { oldestHandle = audioHandle; break; } else if (!audioHandle.looping) { if (audioHandle.timeLastPlayed < oldestTime) { oldestHandle = audioHandle; oldestTime = audioHandle.timeLastPlayed; } } } if (oldestHandle != null) { oldestHandle.stop(); oldestHandle.destroy(); AudioHandles.Remove(oldestHandle); } else { break; } } }
public static bool csWork(String action, String actionData) { if (action == "CCDeviceAudioManager::Reset") { MainPage.m_d3dInterop.csActionResult("CCDeviceAudioManager::Reseted", ""); for (int i = 0; i < AudioHandles.Count; ++i) { AudioHandle audioHandle = AudioHandles[i]; if (audioHandle.mediaElement != null) { audioHandle.stop(); } } return(true); } else if (action == "CCDeviceAudioManager::Prepare") { MainPage.m_d3dInterop.csActionResult("CCDeviceAudioManager::Prepare", ""); String[] split = Regex.Split(actionData, ", "); if (split.Length == 3) { String id = split[0]; String url = split[1]; String path = split[2]; Prepare(id, url, path); } return(true); } else if (action == "CCDeviceAudioManager::Play") { MainPage.m_d3dInterop.csActionResult("CCDeviceAudioManager::Play", ""); String[] split = Regex.Split(actionData, ", "); if (split.Length == 5) { String id = split[0]; String url = split[1]; String path = split[2]; bool restart = split[3].Equals("true"); bool loop = split[4].Equals("true"); AudioHandle audioHandle = Prepare(id, url, path); if (audioHandle != null) { audioHandle.play(restart, loop); } } return(true); } else if (action == "CCDeviceAudioManager::Stop") { MainPage.m_d3dInterop.csActionResult("CCDeviceAudioManager::Stop", ""); AudioHandle audioHandle = Get(actionData); if (audioHandle != null) { audioHandle.stop(); } return(true); } else if (action == "CCDeviceAudioManager::Pause") { MainPage.m_d3dInterop.csActionResult("CCDeviceAudioManager::Pause", ""); AudioHandle audioHandle = Get(actionData); if (audioHandle != null) { audioHandle.pause(); } return(true); } else if (action == "CCDeviceAudioManager::Resume") { MainPage.m_d3dInterop.csActionResult("CCDeviceAudioManager::Resume", ""); AudioHandle audioHandle = Get(actionData); if (audioHandle != null) { audioHandle.resume(false); } return(true); } else if (action == "CCDeviceAudioManager::SetTime") { MainPage.m_d3dInterop.csActionResult("CCDeviceAudioManager::SetTime", ""); return(true); } else if (action == "CCDeviceAudioManager::SetVolume") { MainPage.m_d3dInterop.csActionResult("CCDeviceAudioManager::SetVolume", ""); return(true); } return(false); }