views:

222

answers:

5

Yahoo IM has a neat trick. If you post a URL link to a youtube video, it displays in it's place a flash player with that url's video loaded.

I would like to do the same for my Delphi(7) based chat room (www.magchat.com). The display component is TRichView.

I've scoured Google and sent numerous emails without any success... anyone have any suggestions?

The effect I am trying to achieve is when a User posts a URL link to youtube in the chat program... main form using the TRichView Component... the program would spawn a flash player instead of the url, with the movie playing from the url link. I don't have any idea how to amake this happen, but as I said, I've seen this done in Yahoo's IM program, so it's apparently possible.

There isn't any way to embed twebbrowser in the TRichView Component that I am aware of. I was assuming this would have to be some sort of flash player called when the url is detected. The TRichView Component does support flash.

I hope that's clear. I'm not sure my initial questions was completely clear.

Thanks in advance,

Mark Gundy www.magchat.com

+1  A: 

Whenever you see a http://www.youtube.com/watch URL with a v parameter, just include the following HTML snippet:

<object width="425" height="344">
<param name="movie" value="http://www.youtube.com/v/[video-id]&amp;hl=en&amp;fs=1&amp;"&gt;
</param>
<param name="allowFullScreen" value="true">
</param>
<param name="allowscriptaccess" value="always">
</param>
<embed src="http://www.youtube.com/v/[video-id]&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344">
</embed>
</object>

replacing each occurrence of [video-id] with the v parameter from the URL.

The above HTML snippet is just the "Embed" code taken straight from the page for a random YouTube video. You can tweak some of the parameters like the size, etc.

Laurence Gonsalves
A: 

That might work if this were a webpage, but it's a Windows application, written in Delphi 7 and using for the display component, trichview.

Thanks for the response but I don't think that works for this situation ;-(

Mark Gundy www.magchat.com

I'm not sure it's possible to embed twebbrowser into trichview and if so, I would love to know how. We embed twebbrowser now, but into separate forms (tabs).

MarkGundy
Mark, this isn't a newsgroup. Please don't post answers like you're replying. Add additional information as a comment to the person who answered, or edit your original post to include the additional info. That being said, Laurence is right. You can embed TWebBrowser in your application and use the snippet of HTML he provided to accomplish the same thing in your Delphi Win32 app. Of course, this will introduce a dependency on IE into your app, but that may be something you can live with.
Ken White
A: 

TRichView already knows how to display HTML, right? You shouldn't need to embed a TWebBrowser in it. So can't you insert the HTML that Laurence's answer demonstrates? You said the component supports Flash, after all.

If it turns out TRichView doesn't support Flash, then try embedding it as a Delphi control, instead. You already asked how to do that. TRichView says it knows how to insert Delphi controls, so import the Flash ActiveX player into Delphi; that will define a Delphi component, which you should be able to put onto the TRichView.

Rob Kennedy
A: 

To be able to embed a youtube video in a Delphi win32 app you need to wrap the flash activeX control into a component, so Watch this video.

To display the video just set the movie property of the TShockWaveFlash component. If your url is http://www.youtube.com/watch?v=oGeCqRfRAcQ - convert this to http://www.youtube.com/v/oGeCqRfRAcQ&amp;hl=en&amp;fs=1

It seems to take awhile for the video to become available, and doesn't seem to work the first time I run the application, no idea why, but I'll let you solve that one (it's the first time I've tried this).

Alister
A: 

You might also want to look into oEmbed. It's a standard way to request the embedded version of a media file so you don't have to do any of the search/replace recommended by other users. Here's a YouTube example:

You have a YouTube URL:

http://youtube.com/watch?v=M3r2XDceM6A

You make a request to YouTube's oEmbed endpoint to get the embed code:

http://www.youtube.com/we/love/oembed/?url=http%3A//youtube.com/watch%3Fv%3DM3r2XDceM6A&amp;format=json

And they return a JSON response that includes an HTML snippet:

{
    "version": "1.0",
    "type": "video",
    "provider_name": "YouTube",
    "provider_url": "http://youtube.com/",
    "width": 425,
    "height": 355,
    "title": "Amazing Nintendo Facts",
    "html":
     "<object width=\"425\" height=\"355\">
      <param name=\"movie\" value=\"http://www.youtube.com/v/M3r2XDceM6A&amp;hl=en\"&gt;&lt;/param&gt;
      <param name=\"wmode\" value=\"transparent\"></param>
      <embed src=\"http://www.youtube.com/v/M3r2XDceM6A&amp;hl=en\" type=\"application/x-shockwave-flash\"
       wmode=\"transparent\" width=\"425\" height=\"355\"></embed>
     </object>",
}

oEmbed is also supported by many other websites: Flickr, Viddler, Qik, Hulu, Vimeo, etc.

scompt.com