Skip to main content

Microsoft Silverlight

Answered Question Adding You Tube Media RSS Feed

(0)

sivangari
sivangari

Member

Member

15 points

56 Posts

Adding You Tube Media

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.

Sivangari.V
Chennai,India

tanmoy.r
tanmoy.r

Contributor

Contributor

3594 points

710 Posts

Re: Adding You Tube Media

 The video you are giving is from youtube and in .flv format. Silverlight does not support .flv format. So you are getting this error.

Please Mark as Answer if this helps you.
Thanks n Regards
~Tanmoy
Blog: http://anothersilverlight.blogspot.com/

sivangari
sivangari

Member

Member

15 points

56 Posts

Re: Adding You Tube Media

Then how can i add my you tube in to silverlight application.

Sivangari.V
Chennai,India

tanmoy.r
tanmoy.r

Contributor

Contributor

3594 points

710 Posts

Re: Re: Adding You Tube Media

 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.

Please Mark as Answer if this helps you.
Thanks n Regards
~Tanmoy
Blog: http://anothersilverlight.blogspot.com/

sivangari
sivangari

Member

Member

15 points

56 Posts

Re: Re: Adding You Tube Media

can you tell me how?? or any samples.

Sivangari.V
Chennai,India

tanmoy.r
tanmoy.r

Contributor

Contributor

3594 points

710 Posts

Answered Question

Re: Re: Re: Adding You Tube Media

 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
        }

4. From javascript you can call this Silverlight function with                           control.Content.ScriptObj.SilverlightMethod1(some_param)

 5. Now you can call this javascript code from Flash.

 

 

Please Mark as Answer if this helps you.
Thanks n Regards
~Tanmoy
Blog: http://anothersilverlight.blogspot.com/

tanmoy.r
tanmoy.r

Contributor

Contributor

3594 points

710 Posts

Re: Re: Re: Adding You Tube Media

 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
        }

4. From javascript you can call this Silverlight function with                           control.Content.ScriptObj.SilverlightMethod1(some_param)

 5. Now you can call this javascript code from Flash.

 

 

Please Mark as Answer if this helps you.
Thanks n Regards
~Tanmoy
Blog: http://anothersilverlight.blogspot.com/

kumar103
kumar103

Member

Member

9 points

28 Posts

Re: Re: Re: Adding You Tube Media

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 Telight
Sunny Te...

Member

Member

6 points

3 Posts

Re: Re: Re: Adding You Tube Media

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).

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities