[Demo] How to insert YouTube video in the editor

Demos, code samples. Only questions related to the existing topics are allowed here.
Sergey Tkachenko
Site Admin
Posts: 13563
Joined: Sat Aug 27, 2005 10:28 am
Contact:

[Demo] How to insert YouTube video in the editor

Post by Sergey Tkachenko » Tue Feb 09, 2010 3:11 pm

This demo shows how to insert a YouTube video in TRichViewEdit:
http://www.trichview.com/support/files/youtube.zip

This demo uses "Shockwave Flash" ActiveX (as TShockWaveFlash component).

The user enters the video URL (in the form http://www.youtube.com/watch?v=VIDEOID). The program creates TShockWaveFlash control and assign its Movie property to play the specified video.

ekoindri
Posts: 19
Joined: Sun May 30, 2010 10:00 pm
Location: Indonesia

Post by ekoindri » Mon Aug 02, 2010 9:21 am

Could you show me how to save TRichViewEdit + Youtube to HTML file?

Is this possible to be done?
If this can be realized, it will be so amazing.

Sergey Tkachenko
Site Admin
Posts: 13563
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko » Mon Aug 02, 2010 3:54 pm

Use OnSaveComponentToFile event:

Code: Select all

procedure TForm1.RichViewEdit1SaveComponentToFile(Sender: TCustomRichView;
  Path: String; SaveMe: TPersistent; SaveFormat: TRVSaveFormat;
  var OutStr: String);
begin
  if (SaveFormat=rvsfHTML) and (SaveMe is TShockwaveFlash) then begin
     OutStr := Format(
       '<object width="%d" height="%d">'+
        '<param name="movie" value="%s"></param>'+
        '<param name="allowFullScreen" value="true"></param>'+
        '<param name="allowscriptaccess" value="always"></param>'+
        '<embed src="%s" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="%d" height="%d"></embed>'+
       '</object>',
         [TShockwaveFlash(SaveMe).Width, TShockwaveFlash(SaveMe).Height,
          TShockwaveFlash(SaveMe).Movie,
          TShockwaveFlash(SaveMe).Movie,
          TShockwaveFlash(SaveMe).Width, TShockwaveFlash(SaveMe).Height]);
  end;
end;

ekoindri
Posts: 19
Joined: Sun May 30, 2010 10:00 pm
Location: Indonesia

Post by ekoindri » Tue Aug 03, 2010 1:22 am

@Sergey Tkachenko

Wow...your code above work properly.
Now, I have a problem.
When I sent it via email and I open it with Microsoft OutLook, I can not see
the youtube. What I have to do in order to see the video from email.

Actually, I want to send mass email to my friends and they can see the
video when open the email.

Do you think that this issue is possible to be done by TRichView?

Sergey Tkachenko
Site Admin
Posts: 13563
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko » Tue Aug 03, 2010 7:18 am

I am afraid no, this problem cannot be solved in TRichView.
Either Outlook does not support flash objects, or some (security) settings must be changed in it to view youtube videos.
Sorry, I do not use Outlook myself.

ekoindri
Posts: 19
Joined: Sun May 30, 2010 10:00 pm
Location: Indonesia

Post by ekoindri » Tue Aug 03, 2010 12:58 pm

@Sergey Tkachenko

Thanks for your explanation. You're right, MS OutLook does not support for
showing the youtube video directly. It seems that I have to create it by
myself, so I do not need to use Microsoft Outlook anymore.

Any way, your code above has provided me a hint so useful to achieve this
issue.

regards,


Eko Indriyawan

Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin » Mon May 30, 2011 12:12 am

Just tried this demo on Delphi 2010 under Windows 7 x64 with Adobe Flash 10.2 installed.
It works but during insert I'm getting some EInvalidOp with message 'Invalid floating point operation' errors and Access violation at address 608C89B1 in module 'Flash10o.ocx'. Write of address 0000566D.
Didn't check the code yet just wanted to inform about these errors.

Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin » Mon May 30, 2011 12:13 am

Also when I close application with YouTube inside RVE I'm getting AccessViolation again. But YouTube plays and inserts fine.

Sergey Tkachenko
Site Admin
Posts: 13563
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko » Mon May 30, 2011 6:26 pm

In my tests, calling RichViewEdit1.Clear in FormClose fixed the problem with error on closing.

Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin » Sun Jun 05, 2011 8:23 am

If you click Flash control before it's completely loaded you'll get some Invalid Pointer operation errors, access violations etc...

Sergey Tkachenko
Site Admin
Posts: 13563
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko » Sun Jun 05, 2011 3:30 pm

Do you have ideas how to fix it? AFAIK, these problems are not related to our components

Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin » Tue Jun 07, 2011 6:40 am

Actually I don't know how to fix it yet. Will try to find a way.
Never worked with ActiveX (I think it's a bad thing) but maybe there is a way to check when somebody clicks on flash control and put some try-except routines...
Actually did you get the same errors clicking on flash?

Sergey Tkachenko
Site Admin
Posts: 13563
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko » Tue Jun 07, 2011 6:16 pm

I tried. No, I do not get errors when I click the object immediately after creating it.

Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin » Thu Jun 16, 2011 7:13 am

Try to click several times... I just tried again and got (from 3-4th click):

Code: Select all

---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EInvalidOp with message 'Invalid floating point operation'.
---------------------------
Break   Continue   Help   
---------------------------
AND

Code: Select all

---------------------------
Project
---------------------------
Access violation at address 5DE389B1 in module 'Flash10o.ocx'. Write of address 0000566D.
---------------------------
OK   
---------------------------

Sergey Tkachenko
Site Admin
Posts: 13563
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko » Thu Jun 16, 2011 4:10 pm

I cannot reproduce, no matter how many times I click :(

Post Reply