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());
        }
Exemplo n.º 2
0
 /// <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);
         }
     }
 }
Exemplo n.º 3
0
 /// <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;
         }
     }
 }
Exemplo n.º 4
0
 private void InitAudio()
 {
     if (_filePath == null)
     {
         throw new ArgumentException("ÎÞЧµÄÊôÐÔ FilePath");
     }
     else
     {
         a = new Microsoft.DirectX.AudioVideoPlayback.Audio(_filePath);
     }
 }
Exemplo n.º 5
0
 private void InitAudio()
 {
     if (_filePath == null)
     {
         throw new ArgumentException("�������� FilePath");
     }
     else
     {
         a = new Microsoft.DirectX.AudioVideoPlayback.Audio(_filePath);
     }
 }
Exemplo n.º 6
0
 /// <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);
         }
     }
 }
Exemplo n.º 7
0
 /// <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);
         }
     }
 }
Exemplo n.º 8
0
 /// <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;
         }
     }
 }
Exemplo n.º 9
0
 /// <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;
     }
 }
Exemplo n.º 10
0
 /// <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);
         }
     }
 }
Exemplo n.º 11
0
 /// <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;
     }            
 }