-
-
Notifications
You must be signed in to change notification settings - Fork 0
Using oEmbed With Unknown Providers
On many applications, you may not have any idea what the object is that you or your end users would like to embed into the site. In these instances, you cannot explicitly ask for and use a YouTube object or another object. You will need to dynamically determine and deliver what the social media object is, and return it. Here is how this is done.
The end-user in your application will enter the text. In some cases, it might reflect the text below:
http://www.youtube.com/watch?v=hQTrUpmIgH0
Entering the URL alone would usually not do anything all on it's own. However, when you use the oEmbed API, the URL will "automagically" be turned into the video found at the preceding URL. The magic part only happens for the end-user, not you. :P
You will then take this input and ask the oEmbed API to parse for and return the appropriate social media object to render in your application:
Dim strInput As String = "http://www.youtube.com/watch?v=hQTrUpmIgH0"
Dim ctlOEmbed As New Wrapper
Dim strOutput As String = Me.MediaLiteral.Text = ctlOEmbed.GetContent(New RequestInfo(strInput))
Response.Write(strOutput)
The output that gets returned will look similar to the example below:
<object width="425" height="344">
<param name="movie" value="http://www.youtube.com/watch?v=hQTrUpmIgH0&fs=1"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/watch?v=hQTrUpmIgH0&fs=1" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="always" allowfullscreen="true"></embed>
</object>