Page 1 of 3
[Demo] How to insert YouTube video in the editor
Posted: Tue Feb 09, 2010 3:11 pm
by Sergey Tkachenko
This demo shows how to insert a YouTube video in a Delphi application using TRichViewEdit:
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.
Update: Unfortunately, the result now looks like this:
- watch-on-youtube.png (180.65 KiB) Viewed 56627 times
But when exported in HTML and viewed in a browser, it looks correctly.
- [+] History of updates
-
2018-Apr-21: for compatibility with TRichView 17.3. Also, format of YouTube URL is updated (HTTPS is accepted).
- [+] Old versions
-
http://www.trichview.com/support/files/youtube.zip - for TRichView 17.2 and older
Posted: Mon Aug 02, 2010 9:21 am
by ekoindri
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.
Posted: Mon Aug 02, 2010 3:54 pm
by Sergey Tkachenko
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;
Posted: Tue Aug 03, 2010 1:22 am
by ekoindri
@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?
Posted: Tue Aug 03, 2010 7:18 am
by Sergey Tkachenko
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.
Posted: Tue Aug 03, 2010 12:58 pm
by ekoindri
@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
Posted: Mon May 30, 2011 12:12 am
by Marsianin
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.
Posted: Mon May 30, 2011 12:13 am
by Marsianin
Also when I close application with YouTube inside RVE I'm getting AccessViolation again. But YouTube plays and inserts fine.
Posted: Mon May 30, 2011 6:26 pm
by Sergey Tkachenko
In my tests, calling RichViewEdit1.Clear in FormClose fixed the problem with error on closing.
Posted: Sun Jun 05, 2011 8:23 am
by Marsianin
If you click Flash control before it's completely loaded you'll get some Invalid Pointer operation errors, access violations etc...
Posted: Sun Jun 05, 2011 3:30 pm
by Sergey Tkachenko
Do you have ideas how to fix it? AFAIK, these problems are not related to our components
Posted: Tue Jun 07, 2011 6:40 am
by Marsianin
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?
Posted: Tue Jun 07, 2011 6:16 pm
by Sergey Tkachenko
I tried. No, I do not get errors when I click the object immediately after creating it.
Posted: Thu Jun 16, 2011 7:13 am
by Marsianin
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
---------------------------
Posted: Thu Jun 16, 2011 4:10 pm
by Sergey Tkachenko
I cannot reproduce, no matter how many times I click