Below is the code behind for my mediaplayer. I am trying to populate the playlist with information retrieved from a WCF web service. The player loads and the web service works as far as retrieving data, but i can't set the RadMediaPlayer.ItemsSource with the collection of RadMediaItems. Where am I going wrong?
public partial class MainPage : UserControl |
{ |
ObservableCollection<RadMediaItem> itemsSource = new ObservableCollection<RadMediaItem>(); |
public MainPage() |
{ |
InitializeComponent(); |
mPlayer.ItemsSource = itemsSource; |
} |
private void LoadPlaylist() |
{ |
GalleryPlaylistClient client = new GalleryPlaylistClient(); |
client.GetPlaylistMediaCompleted += new EventHandler<GetPlaylistMediaCompletedEventArgs>(client_GetPlaylistMediaCompleted); |
client.GetPlaylistsAsync(); |
} |
void client_GetPlaylistMediaCompleted(object sender, GetPlaylistMediaCompletedEventArgs e) |
{ |
var items = e.Result; |
foreach (MediaFile item in items) |
{ |
RadMediaItem media = new RadMediaItem(); |
media.Source = new Uri(item.SourceUrl, UriKind.RelativeOrAbsolute); |
media.Title = item.Title; |
media.Description = item.Description; |
media.VideoHeight = item.Height; |
media.VideoWidth = item.Width; |
media.ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(item.ThumbnailUrl, UriKind.RelativeOrAbsolute)); |
itemsSource.Add(media); |
} |
} |
private void mPlayer_Loaded(object sender, System.Windows.RoutedEventArgs e) |
{ |
LoadPlaylist(); |
} |
} |