示例#1
0
        /// <summary>
        /// Starts the plugin.
        /// </summary>
        /// <param name="config">The configuration object for this plugin</param>
        /// <param name="context">The context for this plugin</param>
        /// <returns>Always true</returns>
        public bool StartPlugin(Config config, IPluginContext context)
        {
            var path = Path.Combine(new FileInfo(this.GetType().Assembly.Location).DirectoryName, @"lib\Bass.Net");

            Bass.LoadMe(path);
            BassMix.LoadMe(path);
            Bass.BASS_PluginLoadDirectory(Path.Combine(path, "plugins"));
            _player = new Player();
            PluginManager.Register(_player);
            return(true);
        }
        private void LoadBassLibraries(string targetPath)
        {
            if (!Bass.LoadMe(targetPath))
            {
                throw new BassException("Could not load bass native libraries from the following path: " + targetPath);
            }

            if (!BassMix.LoadMe(targetPath))
            {
                throw new BassException("Could not load bassmix library from the following path: " + targetPath);
            }

            if (!BassFx.LoadMe(targetPath))
            {
                throw new BassException("Could not load bassfx library from the following path: " + targetPath);
            }

            DummyCallToLoadBassLibraries();
        }
示例#3
0
        public static void InitResources(IntPtr win, string bassEmail, string bassCode)
        {
            //This function shall only be executed once! At least NUnit has a problem if executed multiple times.
            if (isInitialized)
            {
                return;
            }

            string targetPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            //if (Utils.Is64Bit)
            //    targetPath = Path.Combine(targetPath, "libs/x64");
            //else
            //    targetPath = Path.Combine(targetPath, "libs/x86");

            if (!string.IsNullOrEmpty(bassEmail) && !string.IsNullOrEmpty(bassCode))
            {
                BassNet.Registration(bassEmail, bassCode);
            }

            if (Utility.IsWindowsOS())
            {
#if __MonoCS__
                //mono specific code for linux. LoadMe is not available and not needed.
#else
                //for Windows
                Bass.LoadMe();
                BassMix.LoadMe();
                BassFlac.LoadMe();
                BassAac.LoadMe();
#endif
            }

            bool isBassInit = Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, win);

            if (!isBassInit)
            {
                throw new ApplicationException("Some errors occurred while initializing audio dll");
            }

            isInitialized = true;
        }
示例#4
0
 public bool BassMixLoadMe(string targetPath)
 {
     return(BassMix.LoadMe(targetPath));
 }
示例#5
0
        public bool Init()
        {
            IntPtr handle = IntPtr.Zero;

            string appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            string targetPath;

            if (Un4seen.Bass.Utils.Is64Bit)
            {
                targetPath = Path.Combine(appPath, "lib/x64");
            }
            else
            {
                targetPath = Path.Combine(appPath, "lib/x86");
            }

            // EXTERNAL PATH SEEMS TO NOT LONGER WORK
            targetPath = appPath;

            this.LibPath = targetPath;

            bool isBassLoadOk    = Bass.LoadMe(targetPath);
            bool isBassMixLoadOk = BassMix.LoadMe(targetPath);

            if (!(isBassLoadOk && isBassMixLoadOk))
            {
                throw new Exception(String.Format("Init error: {0}", Bass.BASS_ErrorGetCode().ToString()));
            }

            this.PluginsLoaded = Bass.BASS_PluginLoadDirectory(targetPath);

            const string allSupportedAudioFilesWord = "All supported Audio Files";
            const string playlistExtFilter          = "*.pls;*.m3u;*.impls";

            string fileSupportedExtFilter = Un4seen.Bass.Utils.BASSAddOnGetPluginFileFilter(PluginsLoaded, allSupportedAudioFilesWord);

            Regex allSupportedFilesPattern = new Regex(allSupportedAudioFilesWord + @"\|(.*?)\|");
            Match match = allSupportedFilesPattern.Match(fileSupportedExtFilter);

            string allSupportedFiles = match.Value;

            allSupportedFiles = String.Format("{0};{1}|", allSupportedFiles.Substring(0, allSupportedFiles.Length - 1), playlistExtFilter);

            fileSupportedExtFilter = fileSupportedExtFilter.Replace(match.Value, allSupportedFiles);

            fileSupportedExtFilter += String.Format("|Playlist|{0}", playlistExtFilter);

            this.FileSupportedExtFilter = fileSupportedExtFilter;

            bool config = Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_NET_PLAYLIST, 0);

            downloadProc = new DOWNLOADPROC(DownloadProcCallback);

            BASS_DEVICEINFO[] devices = Bass.BASS_GetDeviceInfos();

            int devnum = 0;

            foreach (BASS_DEVICEINFO device in devices)
            {
                bool init = Bass.BASS_Init(devnum++, 44100, BASSInit.BASS_DEVICE_DEFAULT, handle);
                if (!init)
                {
                    throw new Exception(String.Format("Init error: {0}", Bass.BASS_ErrorGetCode().ToString()));
                }
            }

            return(true);
        }
示例#6
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 + ")";
            }
        }