void Stop() { if (channel != null) { channel.Stop(); channel = null; } }
public override void Dispose() { if (channel != null) { channel.Stop(); channel = null; } if (sound != null) { sound.Dispose(); sound = null; } base.Dispose(); }
private void timer1_Tick(object sender, EventArgs e) { if (!IsHandleCreated || EditorUtility.IsDesignerHosted(this) || EditorAPI.ClosingApplication) { return; } if (channel != null && channel.Stopped) { channel = null; } buttonPlay.Text = channel == null ? "Play" : "Stop"; buttonLoopPlay.Text = channel == null ? "Loop Play" : "Stop"; //buttonPlay.Text = ToolsLocalization.Translate( "SoundVideoResourceEditor", // ( channel == null ) ? "Play" : "Stop" ); }
public override void StartAudioStream() { if (sound != null) { return; } SoundModes mode = SoundModes.Loop | SoundModes.Stream; int channels = vorbisInfo.channels; int bufferSize = soundBufferSize; if (oggFile.Sound3D) { mode |= SoundModes.Mode3D; if (vorbisInfo.channels == 2) { channels = 1; bufferSize /= 2; } } sound = SoundWorld.SoundCreateDataBuffer(mode, channels, vorbisInfo.rate, bufferSize, ReadData); if (sound == null) { return; } //!!!!attachedToScene channel = SoundWorld.SoundPlay(null, sound, EngineApp.DefaultSoundChannelGroup, 1, true); if (channel != null) { if (oggFile.Sound3D) { channel.Position = oggFile.SoundPosition; } channel.Volume = oggFile.Volume; channel.Pause = oggFile.Pause; } }
void Play(bool loop) { var soundComponent = ObjectForPreview as Component_Sound; if (soundComponent != null && soundComponent.Result != null) { long length = 0; string fileName = soundComponent.LoadFile.Value.ResourceName; if (!string.IsNullOrEmpty(fileName)) { try { length = VirtualFile.GetLength(fileName); //using( var stream = VirtualFile.Open( fileName ) ) // length = (int)stream.Length; } catch { } } if (length != 0) { SoundModes mode = 0; if (Path.GetExtension(fileName).ToLower() == ".ogg" && length > 400000) { mode |= SoundModes.Stream; } if (loop) { mode |= SoundModes.Loop; } sound = soundComponent.Result.LoadSoundByMode(mode); if (sound != null) { channel = SoundWorld.SoundPlay(null, sound, EngineApp.DefaultSoundChannelGroup, .5f); } } } }