//Affichage du temps
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (monfichier != null)
                {
                    int i = (int)monfichier.CurrentPosition;
                    int min = i / 60;
                    int sec = i % 60;
                    Barre_avancement.Value = i;
                    if (min < 10 && sec < 10)
                    {
                        temps.Text = "0" + min.ToString() + ":0" + sec.ToString();
                    }
                    if (min < 10 && sec > 10)
                    {
                        temps.Text = "0" + min.ToString() + ":" + sec.ToString();
                    }
                    if (sec < 10 && min > 10)
                    {
                        temps.Text = min.ToString() + ":0" + sec.ToString();
                    }
                    if (min > 10 && sec > 10)
                    {
                        temps.Text = min.ToString() + ":" + sec.ToString();
                    }

                    if (monfichier.CurrentPosition >= monfichier.Duration)
                    {
                        monfichier.Stop();
                        if (playlist.ContainsKey(index+1))
                        {
                            index++;
                            try
                            {
                                monfichier = new Audio(playlist[index]);
                            }
                            catch
                            {
                                MessageBox.Show("Fichier invalide", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }

                            RAZslidebar();
                            lister();
                            monfichier.Play();
                        }

                    }
                }
        }
Exemple #2
0
 /// <summary>
 /// Resume the current song, if it is paused. Does nothing if it is
 /// not playing or paused.
 /// </summary>
 public void Resume()
 {
     if (isPlaying && currentSong.State == StateFlags.Paused)
     {
         currentSong.Play();
     }
 }
Exemple #3
0
        public void Play()
        {
            if (checkFileName())
            {
                InitVideo();

                if (isVideo)
                {
                    _video.Play();
                }
                else
                {
                    _audio.Play();
                }
                FixSize();
            }
        }
Exemple #4
0
        /// <summary>
        /// Play the given song.
        /// </summary>
        /// <param name="songName"></param>
        /// <param name="loop"></param>
        /// <returns></returns>
        public bool Play(string songName, bool loop)
        {
            LoopCurrentSong = loop;

            string finalPath;

            songName = songName.Replace("/", @"\");
            if (songName.Contains(@"\"))
            {
                currentSongTitle = songName.Substring(songName.LastIndexOf('\\') + 1);
                finalPath        = songName;
            }
            else
            {
                currentSongTitle = songName;
                finalPath        = Path.Combine(audioDirectory, songName);
            }

            currentSongPath = finalPath;

            try
            {
                currentSong = new Microsoft.DirectX.AudioVideoPlayback.Audio(finalPath);
                currentSong.Play();
                currentSong.Volume  = Volume;
                currentSong.Ending += new EventHandler(OnSongEnding);

                isPlaying = true;
            }
            catch (FileNotFoundException)
            {
                return(false);
            }
            catch (DirectXException)
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Play the given song.
        /// </summary>
        /// <param name="songName"></param>
        /// <param name="loop"></param>
        /// <returns></returns>
        public bool Play(string songName, bool loop)
        {
            LoopCurrentSong = loop;

            string finalPath;
            songName = songName.Replace("/", @"\");
            if (songName.Contains(@"\"))
            {
                currentSongTitle = songName.Substring(songName.LastIndexOf('\\') + 1);
                finalPath = songName;
            }
            else
            {
                currentSongTitle = songName;
                finalPath = Path.Combine(audioDirectory, songName);
            }

            currentSongPath = finalPath;

            try
            {
                currentSong = new Microsoft.DirectX.AudioVideoPlayback.Audio(finalPath);
                currentSong.Play();
                currentSong.Volume = Volume;
                currentSong.Ending += new EventHandler(OnSongEnding);

                isPlaying = true;
            }
            catch (FileNotFoundException)
            {
                return false;
            }
            catch (DirectXException)
            {
                return false;
            }

            return true;
        }
        private void suivant()
        {
            if (playlist.Count != 0 && playlist.ContainsKey(index + 1))
            {
                try
                {
                    monfichier.Stop();
                    timer1.Stop();
                    monfichier.Dispose();
                    index++;
                    monfichier = new Audio(playlist[index]);

                }
                catch
                {
                    MessageBox.Show("Fichier invalide", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    supprimer_fichier();
                }
                RAZslidebar();
                lister();
                monfichier.Play();
                timer1.Start();
            }
        }
        //Remplissage de la playliste
        /*Charge le fichier,lance la lecture et lance le timer*/
        private void lancer_fichier()
        {
            if (monfichier == null)
            {
                if (playlist.ContainsKey(index))
                {
                    try
                    {
                        monfichier = new Audio(playlist[index]);
                        monfichier.Play();
                    }
                    catch
                    {
                        MessageBox.Show("Fichier invalide", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                }
            }
            else
            {
                if (monfichier == null)
                    textBox3.Text = "il est nul";
                monfichier.Play();

            }
            timer1.Start();
        }
Exemple #8
0
 public override void Play()
 {
     mAVAudio.Play();
 }