Exemplo n.º 1
0
        /// <summary>
        /// Verify exe exists and setup properties
        /// </summary>
        private void initialize()
        {
            if (string.IsNullOrEmpty(_ffExe))
            {
                throw new ArgumentException("The name does not exist or was not put in");
            }
            string workingPath = Directory.GetCurrentDirectory();

            _ffTarget = workingPath + "\\" + _subDir + "\\" + _ffExe;//building the target
            if (!File.Exists(_ffTarget))
            {
                throw new ArgumentException("Could not find the ffmpeg executable");
            }
            NAudioHandler handler = new NAudioHandler();

            MMDevice[] devices = handler.getDevices();
            this.devices = new string[devices.Length];
            int count = 0;

            foreach (MMDevice d in devices)
            {
                this.devices[count++] = d.ToString();
            }
            //this.devices = handler.getDirectDevices();
            string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            // Combine the base folder with your specific folder....
            storageDir = Path.Combine(folder, "BroadcastLogger");

            // Check if folder exists and if not, create it
            if (!Directory.Exists(storageDir))
            {
                Directory.CreateDirectory(storageDir);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Used to to match a partial device name to a MMDevice.
        /// FFmpeg is limited to only return 31characters of a device
        /// name in Windows 7.
        /// </summary>
        /// <param name="device">Partial string name.</param>
        /// <returns>The MMDevice</returns>
        public static MMDevice MatchDevice(string device)
        {
            NAudioHandler handler = new NAudioHandler();

            MMDevice[] devices = handler.getDevices();

            foreach (MMDevice d in devices)
            {
                string stringDevice = d.ToString();
                for (int i = 0; i < device.Length; i++)
                {
                    Console.Write(stringDevice[i]);
                    if (i == device.Length - 1 && stringDevice[i] == device[i])
                    {
                        return(d);
                    }
                    if (stringDevice[i] != device[i])
                    {
                        break;
                    }
                }
            }
            return(null);
        }