this is just a sample to show how I did a test....
you might want to look at the "SetSource"
SetSource(MediaStreamSource) This sets the source of a MediaElement to a
subclass of MediaStreamSource.
SetSource(Stream) Sets the Source property using the supplied stream.
public partial class Page : UserControl
{
private WebClient wc;
public Page()
{
InitializeComponent();
set1.Click += set1_Click;
set2.Click += set2_Click;
}
private void set1_Click(object sender, RoutedEventArgs e)
{
wc = new WebClient();
wc.OpenReadCompleted += wc_OpenReadCompleted;
wc.OpenReadAsync(new Uri("media/one.wmv", UriKind.Relative));
}
private void set2_Click(object sender, RoutedEventArgs e)
{
wc = new WebClient();
wc.OpenReadCompleted += wc_OpenReadCompleted;
wc.OpenReadAsync(new Uri("media/two.wmv", UriKind.Relative));
}
private void wc_OpenReadCompleted(object sender,
OpenReadCompletedEventArgs e)
{
this.MediaPlayer.SetSource(e.Result);
}
}
On Fri, Jan 30, 2009 at 9:05 PM, Stephen Price <[email protected]>wrote:
> Hey all,
> I'm going spare here. I've got a simple mediaelement, and when I set the
> source in the xaml it works fine. If I set the source in the codebehind it
> doesn't work. It doesn't even seem to hit the url. (using Fiddler aimed at
> www.somesite.com)
>
> has something changed with Uri's?
>
> I've downloaded Tim Heuer's silverlight 2 media player which works. I've
> copied his code (doesn't work) and put my url into his code (works).
>
>
> Application startup has this;
>
> if (!string.IsNullOrEmpty(url)) {
> Uri mediaUri;
>
> if (url.Contains("://")) {
> mediaUri = new Uri(url,
> UriKind.RelativeOrAbsolute);
> }
> else {
> mediaUri = new Uri(url, UriKind.Relative);
> }
>
> this.Resources.Add("url", mediaUri);
>
> }
>
>
> and then I put this into page constructor
>
> videoClipPlayer.Source = App.Current.Resources["url"] as Uri;
>
>
> Am I missing something really obvious or obscure here?
>
> cheers,
> Stephen
> ------------------------------
> Support procedure: https://www.codify.com/lists/support
> List address: [email protected]
> Subscribe: [email protected]
> Unsubscribe: [email protected]
> List FAQ: http://www.codify.com/lists/ozsilverlight
> Other lists you might want to join: http://www.codify.com/lists
--
net noobieâ„¢
=========================
What is the 'Clean Feed'?
No!!! Forced Australian Federal Government Internet Censorship
http://nocleanfeed.com/
--------------------------------------------------------------------------------
Support procedure: https://www.codify.com/lists/support
List address: [email protected]
Subscribe: [email protected]
Unsubscribe: [email protected]
List FAQ: http://www.codify.com/lists/ozsilverlight
Other lists you might want to join: http://www.codify.com/lists