<local:MediaStreamSource Name="mediaSource"><local:MediaStreamSource.Streams><local:StreamResource ResourceName="wildlife.wmv" ResourceLocation="includes.wildlife.wmv"/><local:StreamResource ResourceName="Yami_no_Prologue.mp3" ResourceLocation="includes.Yami_no_Prologue.mp3"/></local:MediaStreamSource.Streams></local:MediaStreamSource>
<local:MediaStreamSource.Streams>
<local:StreamResource ResourceName="wildlife.wmv" ResourceLocation="includes.wildlife.wmv"/>
<local:StreamResource ResourceName="Yami_no_Prologue.mp3" ResourceLocation="includes.Yami_no_Prologue.mp3"/>
</local:MediaStreamSource.Streams>
public class MediaStreamSource : UserControl{ MediaStream streamer; public MediaStreamSource() {
MediaStream streamer;
public MediaStreamSource()
{
Streams = new ObservableCollection<StreamResource>(); Streams.CollectionChanged += Streams_CollectionChanged; streamer = new MediaStream();
Streams = new ObservableCollection<StreamResource>();
Streams.CollectionChanged += Streams_CollectionChanged;
streamer = new MediaStream();
} private void Streams_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) {
}
private void Streams_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) {
if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
foreach (StreamResource resource in e.NewItems)
streamer.RegisterFile(resource.ResourceName, resource.ResourceLocation);
} else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove) {
else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
foreach (StreamResource resource in e.OldItems)
streamer.UnregisterFile(resource.ResourceName);
} else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace) {
else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace)
} else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset) {
else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset)
streamer.UnregisterAllFiles();
} public ObservableCollection<StreamResource> Streams { get; set; } }
public ObservableCollection<StreamResource> Streams { get; set; }
public class StreamResource : UserControl {
public static readonly DependencyProperty ResourceNameProperty =
DependencyProperty.Register("ResourceName", typeof(string), typeof(StreamResource), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public static readonly DependencyProperty ResourceLocationProperty =
DependencyProperty.Register("ResourceLocation", typeof(string), typeof(StreamResource), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public string ResourceName {
public string ResourceName
get { return (string)GetValue(ResourceNameProperty); } set { SetValue(ResourceNameProperty, value); }
get { return (string)GetValue(ResourceNameProperty); }
set { SetValue(ResourceNameProperty, value); }
} public string ResourceLocation {
public string ResourceLocation
get { return (string)GetValue(ResourceLocationProperty); } set { SetValue(ResourceLocationProperty, value); }
get { return (string)GetValue(ResourceLocationProperty); }
set { SetValue(ResourceLocationProperty, value); }