[Demo] How to play AVI files in editor

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

[Demo] How to play AVI files in editor

Post by Sergey Tkachenko »

aviplayer.zip
(3.7 KiB) Downloaded 2473 times
This demo shows:
- how to play AVI files in editor using TPanel and TMediaPlayer
- how to implement resizing of AVI players
- how to export documents containing AVI players to HTML
- how to allow saving and loading documents containing AVI players in RVF

Image

This demo does not support drag&drop of controls. See here for details:
http://www.trichview.com/forums/viewtopic.php?t=157

[+] History of updates
2008-Dec-9: updated according to suggestions below:
- OnItemAction is used to reassign Display;
- hint with file name;
- Rewind button is shown instead of Stop
2018-Apr-8: compatibility with TRichView 17.3
[+] Old versions
http://www.trichview.com/support/files/aviplayer.zip - for TRichView 17.2 and older
Last edited by Sergey Tkachenko on Tue Dec 09, 2008 4:55 pm, edited 1 time in total.
shmp
Posts: 140
Joined: Sun Aug 28, 2005 10:19 am
Location: Sabah, Malaysia.
Contact:

Post by shmp »

Could something be done about this avi procedures? It doesn't seem to work within a table. I tried to figure out but its a very painstaking effort. Need someting less time-consuming.

Thanks in advance.
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, I do not understand your question. Which kind of "avi procedures"?
Guest

Post by Guest »

Sorry for being very brief. Within a table, the resize caused an error. If clicked anywhere other then the panel itself (even outside the table), the resize-procedure is activated thus causing an error. Only when the actual resizing is preformed should the resize-procedure be activated. Could you please check this for me.

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

Post by Sergey Tkachenko »

It looks like TMediaPlayer does not like changing Parent of its Display conntrol.
Use OnItemActionItem to reassign Display:

Code: Select all

procedure TForm1.RichViewEdit1ItemAction(Sender: TCustomRichView;
  ItemAction: TRVItemAction; Item: TCustomRVItemInfo; var Text: String;
  RVData: TCustomRVData);
var Panel, VideoPanel: TPanel;
    Player: TMediaPlayer;
begin
  if csDestroying in Sender.ComponentState then
    exit;
  if (ItemAction=rviaInserted) and (Item.StyleNo=rvsComponent) and
    (TRVControlItemInfo(Item).Control is TPanel) then begin
    Panel      := TRVControlItemInfo(Item).Control as TPanel;
    VideoPanel := Panel.Components[0] as TPanel;
    Player     := Panel.Components[1] as TMediaPlayer;
    Player.Display := VideoPanel;
  end;
end;
shmp
Posts: 140
Joined: Sun Aug 28, 2005 10:19 am
Location: Sabah, Malaysia.
Contact:

Post by shmp »

Many thanks. I will do that.

Cheers :D
wvd_vegt
Posts: 83
Joined: Tue Aug 30, 2005 7:39 am

Post by wvd_vegt »

Hi,

Not related to the problem but nice to add is the next line:

VideoPanel.Hint := Format('%s [%d x %d]', [ExtractFileName(Player.FileName), VideoPanel.Width, VideoPanel.Height]);

which will display a nice yellow hint when the mouse is over the videoplayer.
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

One more suggestion: I just noticed that the TMediaPlayer's Stop button does not reset the movie position to the beginning (so I do not understand what's the difference between Stop and Pause buttons), so hiding additional buttons may be undesirable.
Guest

Post by Guest »

For the player button (namely stop button), I have to reset the position using on notify event - this is one of the incomplete thing in TMediaPlayer. The event is available in the player itself.
gacek999
Posts: 7
Joined: Tue Dec 06, 2005 10:05 pm

Post by gacek999 »

Can we have embedded Windows Media Player control
like TMediaPlayer ? TMediaPlayer also is build on Windows
control, but I want to see original buttons, trackbar, and so on.
We often see this embedded players on websites.
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Create Windows Mediaplayer ActiveX: "Component | Import ActiveX Control", select "Windows Media Player (Version 1.0)", and install it. New control (TWindowsMediaPlayer) will be available in the Component Palette, the page "ActiveX".
Video file name can be specified in URL property. I did not try to insert it in TRichView, but I do not think that there will be problems. It even simpler than the example above, because the control includes both video screen and VCR buttons.
hruslan2000
Posts: 81
Joined: Mon Aug 29, 2005 5:00 am

Post by hruslan2000 »

How to save media source in RVF file with using TWindowsMediaPlayer?

Media player is registered with RegisterClasses([TWindowsMediaPlayer]).
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I think it can be done only by creating inherited component with new property, containing media data.
It's something that was done for the Flash ActiveX here:
http://www.trichview.com/forums/viewtopic.php?t=72
ziclope
Posts: 84
Joined: Wed Aug 31, 2005 10:28 am

Post by ziclope »

Oh it´s great!

Exists any C++Builder demo ?

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

Post by Sergey Tkachenko »

http://www.trichview.com/support/files/ ... ashCPP.zip
It has problems with the flash (see that topic), but may be it will work properly for media player.
Post Reply