home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161b.iso / full / delphi / RUNIMAGE / DELPHI30 / DEMOS / ACTIVEX / DELCTRLS / MPLRIMPL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-08-04  |  10.1 KB  |  419 lines

  1. unit MPlrImpl;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelC_TLB, MPlayer;
  8.  
  9. type
  10.   TMediaPlayerX = class(TActiveXControl, IMediaPlayerX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TMediaPlayer;
  14.     FEvents: IMediaPlayerXEvents;
  15.     procedure ClickEvent(Sender: TObject; Button: TMPBtnType;
  16.       var DoDefault: Boolean);
  17.     procedure NotifyEvent(Sender: TObject);
  18.     procedure PostClickEvent(Sender: TObject; Button: TMPBtnType);
  19.   protected
  20.     { Protected declarations }
  21.     procedure InitializeControl; override;
  22.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  23.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  24.     function Get_AutoEnable: WordBool; safecall;
  25.     function Get_AutoOpen: WordBool; safecall;
  26.     function Get_AutoRewind: WordBool; safecall;
  27.     function Get_Cursor: Smallint; safecall;
  28.     function Get_DeviceID: Smallint; safecall;
  29.     function Get_DeviceType: TxMPDeviceTypes; safecall;
  30.     function Get_Enabled: WordBool; safecall;
  31.     function Get_EndPos: Integer; safecall;
  32.     function Get_Error: Integer; safecall;
  33.     function Get_ErrorMessage: WideString; safecall;
  34.     function Get_FileName: WideString; safecall;
  35.     function Get_Frames: Integer; safecall;
  36.     function Get_Length: Integer; safecall;
  37.     function Get_Mode: TxMPModes; safecall;
  38.     function Get_Notify: WordBool; safecall;
  39.     function Get_NotifyValue: TxMPNotifyValues; safecall;
  40.     function Get_Position: Integer; safecall;
  41.     function Get_Shareable: WordBool; safecall;
  42.     function Get_Start: Integer; safecall;
  43.     function Get_StartPos: Integer; safecall;
  44.     function Get_TimeFormat: TxMPTimeFormats; safecall;
  45.     function Get_Tracks: Integer; safecall;
  46.     function Get_Visible: WordBool; safecall;
  47.     function Get_Wait: WordBool; safecall;
  48.     procedure AboutBox; safecall;
  49.     procedure Back; safecall;
  50.     procedure Close; safecall;
  51.     procedure Eject; safecall;
  52.     procedure Next; safecall;
  53.     procedure Open; safecall;
  54.     procedure Pause; safecall;
  55.     procedure PauseOnly; safecall;
  56.     procedure Play; safecall;
  57.     procedure Previous; safecall;
  58.     procedure Resume; safecall;
  59.     procedure Rewind; safecall;
  60.     procedure Save; safecall;
  61.     procedure Set_AutoEnable(Value: WordBool); safecall;
  62.     procedure Set_AutoOpen(Value: WordBool); safecall;
  63.     procedure Set_AutoRewind(Value: WordBool); safecall;
  64.     procedure Set_Cursor(Value: Smallint); safecall;
  65.     procedure Set_DeviceType(Value: TxMPDeviceTypes); safecall;
  66.     procedure Set_Enabled(Value: WordBool); safecall;
  67.     procedure Set_EndPos(Value: Integer); safecall;
  68.     procedure Set_FileName(const Value: WideString); safecall;
  69.     procedure Set_Frames(Value: Integer); safecall;
  70.     procedure Set_Notify(Value: WordBool); safecall;
  71.     procedure Set_Position(Value: Integer); safecall;
  72.     procedure Set_Shareable(Value: WordBool); safecall;
  73.     procedure Set_StartPos(Value: Integer); safecall;
  74.     procedure Set_TimeFormat(Value: TxMPTimeFormats); safecall;
  75.     procedure Set_Visible(Value: WordBool); safecall;
  76.     procedure Set_Wait(Value: WordBool); safecall;
  77.     procedure StartRecording; safecall;
  78.     procedure Step; safecall;
  79.     procedure Stop; safecall;
  80.   end;
  81.  
  82. implementation
  83.  
  84. uses About15;
  85.  
  86. { TMediaPlayerX }
  87.  
  88. procedure TMediaPlayerX.InitializeControl;
  89. begin
  90.   FDelphiControl := Control as TMediaPlayer;
  91.   FDelphiControl.OnClick := ClickEvent;
  92.   FDelphiControl.OnNotify := NotifyEvent;
  93.   FDelphiControl.OnPostClick := PostClickEvent;
  94. end;
  95.  
  96. procedure TMediaPlayerX.EventSinkChanged(const EventSink: IUnknown);
  97. begin
  98.   FEvents := EventSink as IMediaPlayerXEvents;
  99. end;
  100.  
  101. procedure TMediaPlayerX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  102. begin
  103.   { Define property pages here.  Property pages are defined by calling
  104.     DefinePropertyPage with the class id of the page.  For example,
  105.       DefinePropertyPage(Class_MediaPlayerXPage); }
  106. end;
  107.  
  108. function TMediaPlayerX.Get_AutoEnable: WordBool;
  109. begin
  110.   Result := FDelphiControl.AutoEnable;
  111. end;
  112.  
  113. function TMediaPlayerX.Get_AutoOpen: WordBool;
  114. begin
  115.   Result := FDelphiControl.AutoOpen;
  116. end;
  117.  
  118. function TMediaPlayerX.Get_AutoRewind: WordBool;
  119. begin
  120.   Result := FDelphiControl.AutoRewind;
  121. end;
  122.  
  123. function TMediaPlayerX.Get_Cursor: Smallint;
  124. begin
  125.   Result := Smallint(FDelphiControl.Cursor);
  126. end;
  127.  
  128. function TMediaPlayerX.Get_DeviceID: Smallint;
  129. begin
  130.   Result := Smallint(FDelphiControl.DeviceID);
  131. end;
  132.  
  133. function TMediaPlayerX.Get_DeviceType: TxMPDeviceTypes;
  134. begin
  135.   Result := Ord(FDelphiControl.DeviceType);
  136. end;
  137.  
  138. function TMediaPlayerX.Get_Enabled: WordBool;
  139. begin
  140.   Result := FDelphiControl.Enabled;
  141. end;
  142.  
  143. function TMediaPlayerX.Get_EndPos: Integer;
  144. begin
  145.   Result := FDelphiControl.EndPos;
  146. end;
  147.  
  148. function TMediaPlayerX.Get_Error: Integer;
  149. begin
  150.   Result := FDelphiControl.Error;
  151. end;
  152.  
  153. function TMediaPlayerX.Get_ErrorMessage: WideString;
  154. begin
  155.   Result := WideString(FDelphiControl.ErrorMessage);
  156. end;
  157.  
  158. function TMediaPlayerX.Get_FileName: WideString;
  159. begin
  160.   Result := WideString(FDelphiControl.FileName);
  161. end;
  162.  
  163. function TMediaPlayerX.Get_Frames: Integer;
  164. begin
  165.   Result := FDelphiControl.Frames;
  166. end;
  167.  
  168. function TMediaPlayerX.Get_Length: Integer;
  169. begin
  170.   Result := FDelphiControl.Length;
  171. end;
  172.  
  173. function TMediaPlayerX.Get_Mode: TxMPModes;
  174. begin
  175.   Result := Ord(FDelphiControl.Mode);
  176. end;
  177.  
  178. function TMediaPlayerX.Get_Notify: WordBool;
  179. begin
  180.   Result := FDelphiControl.Notify;
  181. end;
  182.  
  183. function TMediaPlayerX.Get_NotifyValue: TxMPNotifyValues;
  184. begin
  185.   Result := Ord(FDelphiControl.NotifyValue);
  186. end;
  187.  
  188. function TMediaPlayerX.Get_Position: Integer;
  189. begin
  190.   Result := FDelphiControl.Position;
  191. end;
  192.  
  193. function TMediaPlayerX.Get_Shareable: WordBool;
  194. begin
  195.   Result := FDelphiControl.Shareable;
  196. end;
  197.  
  198. function TMediaPlayerX.Get_Start: Integer;
  199. begin
  200.   Result := FDelphiControl.Start;
  201. end;
  202.  
  203. function TMediaPlayerX.Get_StartPos: Integer;
  204. begin
  205.   Result := FDelphiControl.StartPos;
  206. end;
  207.  
  208. function TMediaPlayerX.Get_TimeFormat: TxMPTimeFormats;
  209. begin
  210.   Result := Ord(FDelphiControl.TimeFormat);
  211. end;
  212.  
  213. function TMediaPlayerX.Get_Tracks: Integer;
  214. begin
  215.   Result := FDelphiControl.Tracks;
  216. end;
  217.  
  218. function TMediaPlayerX.Get_Visible: WordBool;
  219. begin
  220.   Result := FDelphiControl.Visible;
  221. end;
  222.  
  223. function TMediaPlayerX.Get_Wait: WordBool;
  224. begin
  225.   Result := FDelphiControl.Wait;
  226. end;
  227.  
  228. procedure TMediaPlayerX.AboutBox;
  229. begin
  230.   ShowMediaPlayerXAbout;
  231. end;
  232.  
  233. procedure TMediaPlayerX.Back;
  234. begin
  235.   FDelphiControl.Back;
  236. end;
  237.  
  238. procedure TMediaPlayerX.Close;
  239. begin
  240.   FDelphiControl.Close;
  241. end;
  242.  
  243. procedure TMediaPlayerX.Eject;
  244. begin
  245.   FDelphiControl.Eject;
  246. end;
  247.  
  248. procedure TMediaPlayerX.Next;
  249. begin
  250.   FDelphiControl.Next;
  251. end;
  252.  
  253. procedure TMediaPlayerX.Open;
  254. begin
  255.   FDelphiControl.Open;
  256. end;
  257.  
  258. procedure TMediaPlayerX.Pause;
  259. begin
  260.   FDelphiControl.Pause;
  261. end;
  262.  
  263. procedure TMediaPlayerX.PauseOnly;
  264. begin
  265.   FDelphiControl.PauseOnly;
  266. end;
  267.  
  268. procedure TMediaPlayerX.Play;
  269. begin
  270.   FDelphiControl.Play;
  271. end;
  272.  
  273. procedure TMediaPlayerX.Previous;
  274. begin
  275.   FDelphiControl.Previous;
  276. end;
  277.  
  278. procedure TMediaPlayerX.Resume;
  279. begin
  280.   FDelphiControl.Resume;
  281. end;
  282.  
  283. procedure TMediaPlayerX.Rewind;
  284. begin
  285.   FDelphiControl.Rewind;
  286. end;
  287.  
  288. procedure TMediaPlayerX.Save;
  289. begin
  290.   FDelphiControl.Save;
  291. end;
  292.  
  293. procedure TMediaPlayerX.Set_AutoEnable(Value: WordBool);
  294. begin
  295.   FDelphiControl.AutoEnable := Value;
  296. end;
  297.  
  298. procedure TMediaPlayerX.Set_AutoOpen(Value: WordBool);
  299. begin
  300.   FDelphiControl.AutoOpen := Value;
  301. end;
  302.  
  303. procedure TMediaPlayerX.Set_AutoRewind(Value: WordBool);
  304. begin
  305.   FDelphiControl.AutoRewind := Value;
  306. end;
  307.  
  308. procedure TMediaPlayerX.Set_Cursor(Value: Smallint);
  309. begin
  310.   FDelphiControl.Cursor := TCursor(Value);
  311. end;
  312.  
  313. procedure TMediaPlayerX.Set_DeviceType(Value: TxMPDeviceTypes);
  314. begin
  315.   FDelphiControl.DeviceType := TMPDeviceTypes(Value);
  316. end;
  317.  
  318. procedure TMediaPlayerX.Set_Enabled(Value: WordBool);
  319. begin
  320.   FDelphiControl.Enabled := Value;
  321. end;
  322.  
  323. procedure TMediaPlayerX.Set_EndPos(Value: Integer);
  324. begin
  325.   FDelphiControl.EndPos := Value;
  326. end;
  327.  
  328. procedure TMediaPlayerX.Set_FileName(const Value: WideString);
  329. begin
  330.   FDelphiControl.FileName := String(Value);
  331. end;
  332.  
  333. procedure TMediaPlayerX.Set_Frames(Value: Integer);
  334. begin
  335.   FDelphiControl.Frames := Value;
  336. end;
  337.  
  338. procedure TMediaPlayerX.Set_Notify(Value: WordBool);
  339. begin
  340.   FDelphiControl.Notify := Value;
  341. end;
  342.  
  343. procedure TMediaPlayerX.Set_Position(Value: Integer);
  344. begin
  345.   FDelphiControl.Position := Value;
  346. end;
  347.  
  348. procedure TMediaPlayerX.Set_Shareable(Value: WordBool);
  349. begin
  350.   FDelphiControl.Shareable := Value;
  351. end;
  352.  
  353. procedure TMediaPlayerX.Set_StartPos(Value: Integer);
  354. begin
  355.   FDelphiControl.StartPos := Value;
  356. end;
  357.  
  358. procedure TMediaPlayerX.Set_TimeFormat(Value: TxMPTimeFormats);
  359. begin
  360.   FDelphiControl.TimeFormat := TMPTimeFormats(Value);
  361. end;
  362.  
  363. procedure TMediaPlayerX.Set_Visible(Value: WordBool);
  364. begin
  365.   FDelphiControl.Visible := Value;
  366. end;
  367.  
  368. procedure TMediaPlayerX.Set_Wait(Value: WordBool);
  369. begin
  370.   FDelphiControl.Wait := Value;
  371. end;
  372.  
  373. procedure TMediaPlayerX.StartRecording;
  374. begin
  375.   FDelphiControl.StartRecording;
  376. end;
  377.  
  378. procedure TMediaPlayerX.Step;
  379. begin
  380.   FDelphiControl.Step;
  381. end;
  382.  
  383. procedure TMediaPlayerX.Stop;
  384. begin
  385.   FDelphiControl.Stop;
  386. end;
  387.  
  388. procedure TMediaPlayerX.ClickEvent(Sender: TObject; Button: TMPBtnType;
  389.   var DoDefault: Boolean);
  390. var
  391.   TempDoDefault: WordBool;
  392. begin
  393.   TempDoDefault := WordBool(DoDefault);
  394.   if FEvents <> nil then FEvents.OnClick(TxMPBtnType(Button), TempDoDefault);
  395.   DoDefault := Boolean(TempDoDefault);
  396. end;
  397.  
  398. procedure TMediaPlayerX.NotifyEvent(Sender: TObject);
  399. begin
  400.   if FEvents <> nil then FEvents.OnNotify;
  401. end;
  402.  
  403. procedure TMediaPlayerX.PostClickEvent(Sender: TObject;
  404.   Button: TMPBtnType);
  405. begin
  406.   if FEvents <> nil then FEvents.OnPostClick(TxMPBtnType(Button));
  407. end;
  408.  
  409. initialization
  410.   TActiveXControlFactory.Create(
  411.     ComServer,
  412.     TMediaPlayerX,
  413.     TMediaPlayer,
  414.     Class_MediaPlayerX,
  415.     15,
  416.     '{FA7B840A-9ED7-11D0-AA40-444553540000}',
  417.     0);
  418. end.
  419.