我正在开发Microsoft UWP。我需要一个播放器来播放两个单独的网址。 MediaElement没有时间轴控件,因此我创建了2个MediaElement并使用以下代码:
AudioPlayer.AutoPlay = false;
AudioPlayer.Source = new Uri("audio url");
MediaPlayer.Source = new Uri("video url");
MediaPlayer.CurrentStateChanged += (sender, args) =>
{
AudioPlayer.Position = MediaPlayer.Position;
if (MediaPlayer.CurrentState == MediaElementState.Paused)
AudioPlayer.Pause();
else if (MediaPlayer.CurrentState == MediaElementState.Playing)
AudioPlayer.Play();
else if (MediaPlayer.CurrentState == MediaElementState.Stopped)
AudioPlayer.Stop();
else
AudioPlayer.Pause();
};
MediaPlayer.SeekCompleted += (sender, args) =>
{
AudioPlayer.Position = MediaPlayer.Position;
};
如何提高效率?