应用程序在一个链接上工作,但在另一个链接不工作

本文关键字:工作 链接 另一个 一个 应用程序 | 更新日期: 2023-09-27 17:57:47

 public partial class MainPage : PhoneApplicationPage
  {
    // varibles and properties
    DispatcherTimer currentPosition = new DispatcherTimer();
    // Constructor
    public MainPage()
    {
        InitializeComponent();
        this.Loaded += new RoutedEventHandler(MainPage_Loaded);
    }
    void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        myMediaElement.MediaOpened += new RoutedEventHandler(myMediaElement_MediaOpened);
        myMediaElement.MediaEnded += new RoutedEventHandler(myMediaElement_MediaEnded);
        myMediaElement.CurrentStateChanged += new RoutedEventHandler(myMediaElement_CurrentStateChanged);
        currentPosition.Tick += new EventHandler(currentPosition_Tick);
        myMediaElement.Source = new Uri("http://url2.bollywoodmp3.se/murder3/%5BSongs.PK%5D%20Murder%203%20-%2007%20-%20Hum%20Jee%20Lenge%20(Rock%20Version).mp3", UriKind.Absolute);
    }
    void myMediaElement_CurrentStateChanged(object sender, RoutedEventArgs e)
    {
        if (myMediaElement.CurrentState == MediaElementState.Playing)
        {
            currentPosition.Start();
            ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = false; // play
            ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = true;  // pause
            ((ApplicationBarIconButton)ApplicationBar.Buttons[2]).IsEnabled = true;  // stop
        }
        else if (myMediaElement.CurrentState == MediaElementState.Paused)
        {
            currentPosition.Stop();
            ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true; // play
            ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = false;  // pause
            ((ApplicationBarIconButton)ApplicationBar.Buttons[2]).IsEnabled = true;  // stop
        }
        else
        {
            currentPosition.Stop();
            ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true; // play
            ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = false;  // pause
            ((ApplicationBarIconButton)ApplicationBar.Buttons[2]).IsEnabled = false;  // stop
        }
    }
    void myMediaElement_MediaEnded(object sender, RoutedEventArgs e)
    {
        myMediaElement.Stop();
    }
    void myMediaElement_MediaOpened(object sender, RoutedEventArgs e)
    {
        pbVideo.Maximum = (int)myMediaElement.NaturalDuration.TimeSpan.TotalMilliseconds;
        myMediaElement.Play();
    }
    void currentPosition_Tick(object sender, EventArgs e)
    {
        pbVideo.Value = (int)myMediaElement.Position.TotalMilliseconds;
    }
    private void Play_Click(object sender, EventArgs e)
    {
        myMediaElement.Play();
    }
    private void Pause_Click(object sender, EventArgs e)
    {
        myMediaElement.Pause();
    }
    private void Stop_Click(object sender, EventArgs e)
    {
        myMediaElement.Stop();
    }
}
}

这是我编写的一个代码,用于从互联网上播放音频文件。在当前链接上,它播放的文件非常好,但我需要播放另一个文件,其链接为"http://108.166.161.206:8826/;stream.mp3"(没有空格(。当我用代码中的给定链接替换此链接时,应用程序不会播放任何内容。有人能帮我解决这个问题吗。提前Thanx。

应用程序在一个链接上工作,但在另一个链接不工作

您拥有的流是Shoutcast媒体,这不是Windows Phone上实现的协议,但您可以使用Code plex中的Shoutcast MediaStreamSource!