Exemple #1
0
        public void PlayWithEndNotifacation(Stream audio, IntPtr hwnd)
        {
            Mp3Stream mp3Stream = new Mp3Sharp.Mp3Stream(audio);

            mp3Stream.Position = 0;
            dev = new Microsoft.DirectX.DirectSound.Device();
            dev.SetCooperativeLevel(hwnd, Microsoft.DirectX.DirectSound.CooperativeLevel.Normal);
            ApplicationStreamedSound = new StreamedMp3Sound(dev, mp3Stream);
            ApplicationStreamedSound.BufferNotification += ApplicationStreamedSound_BufferNotificationSendPostback;
            ApplicationStreamedSound.Play();
        }
Exemple #2
0
 public void Play(Stream audio, IntPtr hwnd)
 {
     if (!IsPlaying)
     {
         IsPlaying           = true;
         _mp3Stream          = new Mp3Sharp.Mp3Stream(audio);
         MyMp3Sream.Position = 0;
         dev = new Microsoft.DirectX.DirectSound.Device();
         dev.SetCooperativeLevel(hwnd, Microsoft.DirectX.DirectSound.CooperativeLevel.Normal);
         ApplicationStreamedSound = new StreamedMp3Sound(dev, MyMp3Sream);
         ApplicationStreamedSound.BufferNotification += ApplicationStreamedSound_BufferNotification;
         ApplicationStreamedSound.Play();
     }
 }
Exemple #3
0
 public static bool TryPlay(Stream audio, IntPtr hwnd)
 {
     try
     {
         Mp3Stream mp3Stream = new Mp3Sharp.Mp3Stream(audio);
         mp3Stream.Position = 0;
         if (mp3Stream.DecodeFrames(1) == 0)
         {
             throw new Exception("Could not decode");
         }
         Device dev = new Microsoft.DirectX.DirectSound.Device();
         dev.SetCooperativeLevel(hwnd, Microsoft.DirectX.DirectSound.CooperativeLevel.Normal);
         StreamedMp3Sound ApplicationStreamedSound = new StreamedMp3Sound(dev, mp3Stream);
         ApplicationStreamedSound.Play();
         ApplicationStreamedSound.Stop();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }