Beispiel #1
0
        //add bookmode to listview, show one entry per books(albums), playing a different book will start from your last position in that book - so you can play other files/books and come back
        //playing a file directly always plays from the start assuming its not loaded/prescrubbed
        //make it a whole other mode, book scrubber by default (also make book scrubber only for current book not for entire library)
        //should be default mode actually, leave multifiles and junk to the program to handle
        //controls should affect book mode when in book mode (prev/next book instead of file)
        public Form1()
        {
            InitializeComponent();
            chkArtPlaying.Parent        = pBoxArt;
            scrubber.Scrubbed          += Scrubber1_Scrubbed;
            fileList.OrderChanged      += fileList_OrderChanged;
            AudioPlayer.AudioPlaying   += AudioPlayer_AudioPlaying;
            AudioPlayer.AudioCompleted += AudioPlayer_AudioCompleted;

            try
            {
                BassNet.Registration("*****@*****.**", "2X3729121152222");
                Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
                //Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_FLOATDSP, true);
                Dictionary <int, string> loadedPlugIns = Bass.BASS_PluginLoadDirectory(System.IO.Directory.GetCurrentDirectory());
                BassFx.LoadMe();
                BassMix.LoadMe();
            }
            catch (Exception e)
            {
                BASSError er = Bass.BASS_ErrorGetCode();
            }


            string folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ABPlayer");

            if (Directory.Exists(folder))
            {
                string file = Path.Combine(folder, "lastOpen.txt");
                if (File.Exists(file))
                {
                    using (FileStream fs = new FileStream(file, FileMode.Open))
                        using (StreamReader sr = new StreamReader(fs))
                        {
                            int           index = Convert.ToInt32(sr.ReadLine());
                            long          ticks = Convert.ToInt64(sr.ReadLine());
                            List <string> files = new List <string>();
                            string        f     = "";
                            while ((f = sr.ReadLine()) != null)
                            {
                                files.Add(f);
                            }
                            AddFiles(files.ToArray());
                            if (files.Count > 0)
                            {
                                playingId = index;
                                playing   = audioFiles[index];
                                PlayFile(index, new TimeSpan(ticks) - audioFiles[index].StartTime, true);
                            }
                        }
                }
                file = Path.Combine(folder, "settings.txt");
                if (File.Exists(file))
                {
                    using (FileStream fs = new FileStream(file, FileMode.Open))
                        using (StreamReader sr = new StreamReader(fs))
                        {
                            AudioPlayer.Volume = Convert.ToSingle(sr.ReadLine());
                            UpdateMono(Convert.ToBoolean(sr.ReadLine()));
                            AudioPlayer.Speed = Convert.ToSingle(sr.ReadLine());
                        }
                }
                tBarVol.Value = (int)(AudioPlayer.Volume * 100);
                lblVol.Text   = tBarVol.Value + "%";
                speedToolStripMenuItem.Text = "Speed (" + AudioPlayer.Speed + ")";
            }
        }