protected override bool PlaySource(Entity e) { var mgr = EntityManager; if (mgr.HasComponent <AudioSource>(e)) { AudioSource audioSource = mgr.GetComponentData <AudioSource>(e); Entity clipEntity = audioSource.clip; if (mgr.HasComponent <AudioHTMLClip>(clipEntity)) { AudioHTMLClip clip = mgr.GetComponentData <AudioHTMLClip>(clipEntity); if (clip.clipID > 0) { if (!unlocked) { AudioHTMLNativeCalls.Unlock(); unlocked = AudioHTMLNativeCalls.IsUnlocked(); if (unlocked) { TinyEnvironment env = World.TinyEnvironment(); AudioConfig ac = env.GetConfigData <AudioConfig>(); ac.unlocked = unlocked; env.SetConfigData(ac); } } if (unlocked) { // If there is an existing source, it should re-start. // Do this with a Stop() and let it play below. if (mgr.HasComponent <AudioHTMLSource>(e)) { AudioHTMLSource ans = mgr.GetComponentData <AudioHTMLSource>(e); AudioHTMLNativeCalls.Stop(ans.sourceID, true); } int sourceID = ++IDPool.sourceID; AudioHTMLNativeCalls.Play(clip.clipID, sourceID, audioSource.volume, audioSource.loop); AudioHTMLSource audioNativeSource = new AudioHTMLSource() { sourceID = sourceID }; // Need a native source as well. if (mgr.HasComponent <AudioHTMLSource>(e)) { mgr.SetComponentData(e, audioNativeSource); } else { PostUpdateCommands.AddComponent(e, audioNativeSource); } return(true); } } } } return(false); }
protected override void StopSource(Entity e) { if (EntityManager.HasComponent <AudioHTMLSource>(e)) { AudioHTMLSource audioNativeSource = EntityManager.GetComponentData <AudioHTMLSource>(e); if (audioNativeSource.sourceID > 0) { AudioHTMLNativeCalls.Stop(audioNativeSource.sourceID, true); } } }
protected override bool IsPlaying(Entity e) { if (EntityManager.HasComponent <AudioHTMLSource>(e)) { AudioHTMLSource audioHtmlSource = EntityManager.GetComponentData <AudioHTMLSource>(e); if (audioHtmlSource.sourceID > 0) { return(AudioHTMLNativeCalls.IsPlaying(audioHtmlSource.sourceID)); } } return(false); }