Reputation: 764
Question is simple but I'm near the solution..
In my windows store project, I need to play video in my video gallery page. I get the url from my web api. I get the "video_id" from selection_changed event, but could not put it into my media element.. My link is ready, I just need to put it in a media element..
this is my xaml side ;
<Grid x:Name="VideoGaleriFlipGrid"
Grid.Column="1"
Grid.Row="1">
<MediaElement x:Name="MyMediaPlayer"
AutoPlay="False"/>
</Grid>
and my cs codes;
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.Parameter == null) return;
var clickedItem = e.Parameter.ToString();
var index = int.Parse(clickedItem);
var url = "http://myapi.mywebsite.com.tr/Video?videoID=" + index;
using (var client = new HttpClient())
{
var videodata = await client.GetStringAsync(url);
_videos = JsonConvert.DeserializeObject<VideoApi.RootObject>(videodata);
//MyMediaPlayer.Source = _videos.Video[1].videourl3;
//MyMediaPlayer.DataContext = _videos.Video[1].videourl3;
}
}
Commented lines doesn't work you know.. And I get the right videodata and right videourl3 when check with breakpoint..
I googled but couldn't find a situation like mine. I need help about this.. Thank you.
Upvotes: 0
Views: 816
Reputation: 15296
Try this
MyMediaPlayer.Source = new Uri(_videos.Video[1].videourl3)
;
Upvotes: 1