Ejemplo n.º 1
0
 private void btnSharpDX_Click(object sender, RoutedEventArgs e)
 {
     InitializeXAudio2();
     fileStream = new NativeFileStream(@"Assets\Clk_1Sec1.mp3", NativeFileMode.Open, NativeFileAccess.Read);
     audioPlayer = new AudioPlayer(xaudio2, fileStream);
     audioPlayer.Play();
 }
Ejemplo n.º 2
0
        //public async void SetPosition(int m, int s, double PlaybackRate)    
        public void SetPosition(int m, int s, double PlaybackRate)
        {
            sw.Reset();
#if (SHARPDXTEST)
            InitializeXAudio2();
            fileStream = new NativeFileStream(@"Assets\Clk_1Sec1.mp3", NativeFileMode.Open, NativeFileAccess.Read);
            audioPlayer = new AudioPlayer(xaudio2, fileStream);
#else
#endif



            TimeSpan ts = new TimeSpan(0, 0, m, s, 1);
            //await me1.SeekAsync(ts);
            me1.Position = ts;
            if ((cbOnlyOneMP3.SelectedItem as string) == "No")
            {
                //await me2.SeekAsync(ts);
                //await me3.SeekAsync(ts);
                //await me4.SeekAsync(ts);
                me2.Position = ts;
                me3.Position = ts;
                me4.Position = ts;
            }

            Debug.WriteLine(string.Format("T:{0:0.0000}  T:{1:0.0000}  T:{2:0.0000}  T:{3:0.0000}", me1.Position.TotalSeconds, me2.Position.TotalSeconds, me3.Position.TotalSeconds, me4.Position.TotalSeconds));











            //TimeSpan ts = new TimeSpan(0, 0, m, s,1);
            //me1.Position = ts;
            //if ((cbOnlyOneMP3.SelectedItem as string) == "No")
            //{
            //    me2.Position = ts;
            //    me3.Position = ts;
            //    me4.Position = ts;
            //}












#if (SHARPDXTEST)
            audioPlayer.Position = ts;
#else
#endif

            Debug.WriteLine(string.Format("-ME1 {0}", me1.CurrentState));
            Debug.WriteLine(string.Format("-ME2 {0}", me2.CurrentState));
            Debug.WriteLine(string.Format("-ME3 {0}", me3.CurrentState));
            Debug.WriteLine(string.Format("-ME4 {0}", me4.CurrentState));
            //await Task.Delay(1000);

            me1.DefaultPlaybackRate = PlaybackRate;
            me1.Play();
            //me1.Volume = 0;
            if ((cbOnlyOneMP3.SelectedItem as string) == "No")
            {
                me2.DefaultPlaybackRate = PlaybackRate;
                me3.DefaultPlaybackRate = PlaybackRate;
                me4.DefaultPlaybackRate = PlaybackRate;

                me2.Play();
                me3.Play();
                me4.Play();
                //me撥放器2.PlaybackRate = PlaybackRate;
                //me撥放器3.PlaybackRate = PlaybackRate;
                //me撥放器4.PlaybackRate = PlaybackRate;
            }
            sw.Start();
#if (SHARPDXTEST)
            audioPlayer.Play();
#else
#endif
        }