コード例 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter the name of the file to play.");
            string filename = Console.ReadLine();

            if (filename.StartsWith("\""))
            {
                filename = filename.Remove(0, 1);
            }
            if (filename.EndsWith("\""))
            {
                filename = filename.Remove(filename.Length - 1);
            }
            if (!File.Exists(filename))
            {
                Console.WriteLine("File not found.");
                Environment.Exit(0);
            }
            MediaFoundationProvider provider = new MediaFoundationProvider(filename);
            MediaFoundationPlayer   player   = new MediaFoundationPlayer();

            player.Init(provider);
            while (!player.Prepared)
            {
            }
            player.PlayFromBegining();
            while (player.PlaybackState != NAudio.Wave.PlaybackState.Stopped)
            {
            }
        }
コード例 #2
0
        public void CanPlay()
        {
            string url = @"G:\Chevy\Music\Unravel.mp3";

            if (!File.Exists(url))
            {
                Assert.Ignore("Missing test file");
            }
            MediaFoundationProvider provider = new MediaFoundationProvider(url);
            MediaFoundationPlayer   player   = new MediaFoundationPlayer();

            player.Init(provider);
            while (!player.Prepared)
            {
            }
            player.Play();
        }