2015-02-10 115 views
0

我想給一個MediaElement的源單擊某個按鈕時,然後播放媒體,這是我到目前爲止有:的MediaElement拋出錯誤

在我的XAML:

<MediaElement x:Name="vid" HorizontalAlignment="Left" Height="100" Margin="310,193,0,0" Grid.Row="1" VerticalAlignment="Top" Width="100" Source="Assets/Stars.mov"/> 

在類:

private void Button1_Click(object sender, RoutedEventArgs e) 
    { 
     this.vid.Source = new Uri("Assets/Stars.mov", UriKind.Relative); 
     vid.Play(); 
    } 

不過,我收到此錯誤:

An exception of type 'System.ArgumentException' occurred in mscorlib.dll but was not handled in user code 
Additional information: The given System.Uri cannot be converted into a Windows.Foundation.Uri. Please see http://go.microsoft.com/fwlink/?LinkID=215849 for details. 

有誰知道我做錯了什麼?

+0

它關係到WPF或贏的應用程序? – 2015-02-10 16:15:53

+0

@RahulSharma對不起,Windows App – 2015-02-10 16:18:01

+0

[給定的System.Uri不能轉換成Windows.Foundation.Uri]的可能的重複(http://stackoverflow.com/questions/7569720/the-given-system-uri -cannot-be-converted-into-a-windows-foundation-uri) – RobH 2015-02-10 16:29:00

回答