Exemplo n.º 1
0
        public PlayAll(Playbackband pbb, string directoryToUse)
        {
            InitializeComponent();

            this.directoryToUse = directoryToUse;
            playbackband = pbb;
            //play_thread = new System.Threading.Thread(backgroundWorker1_DoWork);
            //play_thread.SetApartmentState(System.Threading.ApartmentState.STA);

            player1 = new MediaPlayer();
            player2 = new MediaPlayer();
        }
Exemplo n.º 2
0
        private void UpdatePlayer()
        {
            if (setPlayerActive)
            {
                if (liedje != null)
                {
                    if (!liedje.IsDummy())
                    {
                        if (this.filename == "")
                        {
                            this.filename = liedje.Liedje.WriteToFile(File.defaultDir + "\\" + DateTime.Now.Ticks.ToString() + ".mp3");

                            mp = new MediaPlayer(liedje.Liedje, this.filename);
                            mp.WaardesAangepast += mp_WaardesAangepast;
                            mp.RefeshData += mp_RefeshData;
                            mp.Parent = panel7;
                            mp.Location = new Point(10, 35);
                            mp.SetFragmentProperties(liedje.BeginTijd, liedje.EindTijd, liedje.FadeIn, liedje.FadeOut, liedje.FadeInBinnen, liedje.FadeOutBinnen);

                            //mp_WaardesAangepast(mp);
                        }
                    }
                }
            }
            else
            {
                if (mp != null)
                {
                    //mp.Dispose();
                    //mp = null;
                    //System.IO.File.Delete(filename);
                }
            }
        }
Exemplo n.º 3
0
        private void mp_WaardesAangepast(MediaPlayer sender)
        {
            liedje.BeginTijd = GetTimeFromDouble(sender.BegintijdFragment);
            liedje.EindTijd = GetTimeFromDouble(sender.EindtijdFragment);
            liedje.FadeIn = GetTimeFromDouble(sender.FadeInLength);
            liedje.FadeOut = GetTimeFromDouble(sender.FadeOutLength);
            liedje.FadeInBinnen = sender.FIBinnen;
            liedje.FadeOutBinnen = sender.FOBinnen;
            liedje.RodeDraad = this.rodeDraad;

            label3.Text = GetTimeFromDouble(sender.BegintijdFragment).ToString("mm.ss") + " - " + GetTimeFromDouble(sender.EindtijdFragment).ToString("mm.ss");

            if (RodeDraad == 1)
            {
                OnRodeDraadChanged();
            }
        }
Exemplo n.º 4
0
 void mp_RefeshData(MediaPlayer sender)
 {
     label3.Text = GetTimeFromDouble(sender.BegintijdFragment).ToString("mm.ss") + " - " + GetTimeFromDouble(sender.EindtijdFragment).ToString("mm.ss");
 }
Exemplo n.º 5
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Weet je zeker dat je het muziek fragment wil verwijderen?", "Playbackband maker", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                //OnRenewMe();
                comboBox1.SelectedIndex = 0;

                this.currentPBB.VerwijderFragment(this.liedje);
                this.filename = "";
                this.liedje = new Fragment(this.liedje.Nummer);
                this.mp = null;

                UpdateView();

                button1_Click(null, null);
                button1_Click(null, null);
            }
        }
Exemplo n.º 6
0
 void mp_RefeshData(MediaPlayer sender)
 {
     label3.Text = GetTimeFromDouble(sender.BegintijdFragment).ToString("mm.ss") + " - " + GetTimeFromDouble(sender.EindtijdFragment).ToString("mm.ss");
 }
Exemplo n.º 7
0
 void player_FadeInEnded(MediaPlayer sender)
 {
     while (player1.IsPlaying() && player2.IsPlaying())
     {
         Application.DoEvents();
     }
     CreateNextMediaPlayer(currentIndex);
 }
Exemplo n.º 8
0
 void player2_FadeOutStarted(MediaPlayer sender)
 {
     player1.PlaySelectie();
 }
Exemplo n.º 9
0
        private void CreateNextMediaPlayer(int index, bool autoPlay = false)
        {
            if (index > fragmenten.Count - 1)
            {
                return;
            }

            Fragment f = fragmenten[index];
            while (f.Liedje.FileContent == null)
            {
                index++;
                if (index == fragmenten.Count)
                {
                    if (!player1.IsPlaying()) panel2.Controls.Remove(player1);
                    if (!player2.IsPlaying()) panel2.Controls.Remove(player2);

                    return;
                }
                f = fragmenten[index];
            }

            if (!player1.IsPlaying())
            {
                panel2.Controls.Remove(player1);
                player1 = new MediaPlayer(f.Liedje, f.Liedje.WriteToFile(this.directoryToUse + "\\" + DateTime.Now.Ticks.ToString() + ".mp3"));
                player1.SetFragmentProperties(f.BeginTijd, f.EindTijd, f.FadeIn, f.FadeOut, f.FadeInBinnen, f.FadeOutBinnen);

                player1.FadeInEnded += player_FadeInEnded;
                player1.FadeOutStarted += player1_FadeOutStarted;

                player1.DisplayMode = true;
                //player1.Location = new Point(12, 0);
                player1.Dock = DockStyle.Top;
                player1.Parent = panel2;
                player1.BringToFront();

                if (autoPlay)
                {
                    player1.PlaySelectie();
                }
            }
            else if (!player2.IsPlaying())
            {
                panel2.Controls.Remove(player2);
                player2 = new MediaPlayer(f.Liedje, f.Liedje.WriteToFile(this.directoryToUse + "\\" + DateTime.Now.Ticks.ToString() + ".mp3"));
                player2.SetFragmentProperties(f.BeginTijd, f.EindTijd, f.FadeIn, f.FadeOut, f.FadeInBinnen, f.FadeOutBinnen);

                player2.FadeInEnded += player_FadeInEnded;
                player2.FadeOutStarted +=player2_FadeOutStarted;

                //player2.Location = new Point(12, 81);
                player2.DisplayMode = true;
                player2.Dock = DockStyle.Top;
                player2.Parent = panel2;
                player2.BringToFront();

                if (autoPlay)
                {
                    player2.PlaySelectie();
                }
            }
            else
            {
                throw new Exception("ERROR!");
            }

            currentIndex++;
        }