Ejemplo n.º 1
0
 private void OpenFile()
 {
     Microsoft.Win32.OpenFileDialog openDialog = new Microsoft.Win32.OpenFileDialog();
     openDialog.Filter = "(*.mp3)|*.mp3";
     if (openDialog.ShowDialog() == true)
     {
         NAudioEngine.Instance.OpenFile(openDialog.FileName);
         //FileText.SetCurrentValue(TextBox.TextProperty, openDialog.FileName);
         RunnerText.SetCurrentValue(ContentProperty, openDialog.FileName);
     }
 }
        // Begin dragging the window
        private void PlayListView_OnPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var item = (sender as ListView).SelectedItem;

            if (item != null)
            {
                if (NAudioEngine.Instance.CanStop)
                {
                    NAudioEngine.Instance.Stop();
                }

                var path = (item as TextBlock).Text;
                RunnerText.SetCurrentValue(ContentProperty, path);
                NAudioEngine.Instance.OpenFile(path);
                //FileText.SetCurrentValue(TextBox.TextProperty, openDialog.FileName);
                NAudioEngine.Instance.Play(); //TODO: Doesn't play it
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// convert a file to wav to preview it.
        /// </summary>
        /// <param name="path"></param>
        public void TempConvertToWemWav(string path)
        {
            var ManagerCacheDir = Path.Combine(ISettingsManager.GetTemp_AudioPath());

            //Clean directory
            Directory.CreateDirectory(ManagerCacheDir);

            foreach (var f in Directory.GetFiles(ManagerCacheDir))
            {
                try
                {
                    File.Delete(f);
                }
                catch
                {
                }
            }

            var outf = Path.Combine(ManagerCacheDir, Path.GetFileNameWithoutExtension(path) + ".wav");

            Trace.WriteLine(outf);
            Trace.WriteLine(path);

            var arg = path.ToEscapedPath() + " -o " + outf.ToEscapedPath();
            var p   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "lib", "vgmstream", "test.exe");
            var si  = new ProcessStartInfo(
                p,
                arg
                )
            {
                CreateNoWindow         = true,
                WindowStyle            = ProcessWindowStyle.Hidden,
                UseShellExecute        = false,
                RedirectStandardError  = true,
                RedirectStandardOutput = true,
                Verb = "runas"
            };
            var proc = Process.Start(si);

            proc.WaitForExit();
            Trace.WriteLine(proc.StandardOutput.ReadToEnd());

            mediaPlayer.Open(new Uri(outf));

            var timer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(1)
            };

            timer.Tick += Timer_Tick;

            timer.Start();

            var ChannelPositionTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(1)
            };

            ChannelPositionTimer.Tick += ChannelPositionTimer_Tick;
            ;

            ChannelPositionTimer.Start();

            //ChannelLength = $"{mediaPlayer.Position.TotalMinutes} : {mediaPlayer.Position.TotalSeconds} : {mediaPlayer.Position.TotalMilliseconds}";
            NAudioSimpleEngine.Instance.OpenFile(outf);
            RunnerText.SetCurrentValue(ContentProperty, Path.GetFileNameWithoutExtension(outf));


            //AudioFileList.Add(lvi);
        }