private TimeSpan GetDuration() { // TODO: What should we do if DirectX throws an exception (e.g. the path is really // not a valid audio or video stream)? For now, just ignore exceptions. try { if (SessionComponentDefinition.GetIsAudio(Path)) { using (var audio = new Microsoft.DirectX.AudioVideoPlayback.Audio(Path)) { return(TimeSpan.FromSeconds((int)audio.Duration)); } } else if (SessionComponentDefinition.GetIsVideo(Path)) { using (var video = new Microsoft.DirectX.AudioVideoPlayback.Video(Path)) { return(TimeSpan.FromSeconds((int)video.Duration)); } } } catch (ThreadAbortException) { //fine, just return } catch (Exception e) { Palaso.Reporting.ErrorReport.NotifyUserOfProblem(e, "Could not get duration of " + Path); } return(new TimeSpan()); }
/// <summary> /// Increases volume with a step /// and adjusts the progress bar /// </summary> /// <param name="video">A video object</param> /// <param name="slider">A custom slider object</param> public static void VolumeUp(DirectXAudioAllias audio, CustomSlider slider) { if (slider.Value < MaxProgressBarValue) { slider.Value += VolumeStep; if (CheckException.CheckNull(audio)) { HandleAudio(audio, slider.Value); } } }
/// <summary> /// Initializes the volume of the video at start /// with the value of the progress bar /// </summary> /// <param name="video">A video object</param> /// <param name="slider">A custom slider object</param> public static void VolumeInit(DirectXAudioAllias audio, CustomSlider slider) { if (audio != null) { audio.Volume = Convert.ToInt32(slider.Value * (ValueNormalizer)+MinVolumeValue); if(audio.Volume == MinVolumeValue) { audio.Volume = NoSound; } } }
private void InitAudio() { if (_filePath == null) { throw new ArgumentException("ÎÞЧµÄÊôÐÔ FilePath"); } else { a = new Microsoft.DirectX.AudioVideoPlayback.Audio(_filePath); } }
private void InitAudio() { if (_filePath == null) { throw new ArgumentException("�������� FilePath"); } else { a = new Microsoft.DirectX.AudioVideoPlayback.Audio(_filePath); } }
/// <summary> /// Decreases volume by a step /// and adjusts the progress bar /// </summary> /// <param name="video">A video object</param> /// <param name="slider">A custom slider object</param> public static void VolumeDown(DirectXAudioAllias audio, CustomSlider slider) { if (slider.Value > slider.Minimum) { slider.Value -= VolumeStep; if (CheckException.CheckNull(audio)) { HandleAudio(audio, slider.Value); } } }
/// <summary> /// Initializes the volume of the video at start /// with the value of the progress bar /// </summary> /// <param name="video">A video object</param> /// <param name="slider">A custom slider object</param> public static void VolumeInit(DirectXAudioAllias audio, CustomSlider slider) { if (audio != null) { audio.Volume = Convert.ToInt32(slider.Value * (ValueNormalizer) + MinVolumeValue); if (audio.Volume == MinVolumeValue) { audio.Volume = NoSound; } } }
/// <summary> /// Checks if the value is adequate and sets the volume /// </summary> /// <param name="video">A video object</param> /// <param name="value">An integer value</param> private static void HandleAudio(DirectXAudioAllias audio, int value) { if (value != 0) { audio.Volume = Convert.ToInt32(GetCorrectValue(value)); } else { audio.Volume = NoSound; } }