Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit Adding You Tube Media
8 replies. Latest Post by Sunny Telight on August 28, 2008.
(0)
sivangari
Member
15 points
56 Posts
08-11-2008 10:24 AM |
i havve created a media element and a button in my XAML page.On click of the button i have called the url of you tube like this
aVideo.Source = new Uri("http://www.youtube.com/v/K3kinxTCGOk&hl=en&fs=1", UriKind.Absolute);
but i get error like this
Sys.InvalidOperationException:MediaError #4001 in Control 'XAML1':A_G_E_NETWORK_ERROR
how to rectify this.
tanmoy.r
Contributor
3594 points
710 Posts
08-11-2008 10:28 AM |
The video you are giving is from youtube and in .flv format. Silverlight does not support .flv format. So you are getting this error.
08-11-2008 10:30 AM |
Then how can i add my you tube in to silverlight application.
08-11-2008 10:33 AM |
You can not. What you can do is to have one swf for youtube video player along with the silverlight xap in your html page. You can communicate between them through javascript.
08-11-2008 10:38 AM |
can you tell me how?? or any samples.
08-11-2008 11:03 AM |
Well I dont know how you can call javascript from Flash or call Flash methods from javascript (though I know it is possible).
Here is the logic for it.
Have a div that has your silverlight xap component and another for the swf in the html
Silverlight To Flash
1. Now suppose you want to play http://abcd_youtube_video_url from youtube. Now you get this url in silverlight and want to pass to Flash video player to play it.
3. Have a javascript function like the following
function playFlv( url) {
// pass the url to flash so it can play it.
}
4. Now from silverlight call HtmlPage.Window.Invoke("playFlv", you_tube_url_string);
Flash to Silverlight
1. Suppose you want to call a method SilverlightMethod1 from Flash.
2. Add this to your Page_Loaded event HtmlPage.RegisterScriptableObject("ScriptObj", this);
3. Write the method with [ScriptableMember] on the top like the following
[ScriptableMember]
public void SilverlightMethod1(object o) { // do something inside silverlight }
5. Now you can call this javascript code from Flash.
08-11-2008 11:04 AM |
kumar103
9 points
28 Posts
08-26-2008 7:05 PM |
Anyone figure out more concretely how to do this? I've searching for days about this exact issue and finally came across this post, but still am not understanding how to go about it.
Anyone have some sample code or tutorials regarding this matter?
Thanks
Sunny Te...
6 points
3 Posts
08-28-2008 2:45 PM |
As of right now (possibly ever) you cannot play a flash video directly inside a sliverlight app. tanmoy's example is just for having a flash video and a silverlight app on the same html page and having the silverlight control the flash video (play stop etc).