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:

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 = ""
Dim ctlOEmbed As New Wrapper
Dim strOutput As String = Me.MediaLiteral.Text = ctlOEmbed.GetContent(New RequestInfo(strInput))

The output that gets returned will look similar to the example below:

<object width="425" height="344">
    <param name="movie" value=""></param>
    <param name="allowFullScreen" value="true"></param>
    <param name="allowscriptaccess" value="always"></param>
    <embed src="" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="always" allowfullscreen="true"></embed>

Last edited Sep 16, 2011 at 12:00 AM by hismightiness, version 2


No comments yet.