home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WMEDIA.HPP < prev    next >
C/C++ Source or Header  |  1997-01-27  |  11KB  |  392 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. /*************************************************************************
  12.  *
  13.  * WMediaPlayer -- Wrapper for the Windows 95 Media Player control.
  14.  *
  15.  *
  16.  *   Events:
  17.  *
  18.  *       MediaNotifyError --
  19.  *
  20.  *       MediaNotifyMedia --
  21.  *
  22.  *       MediaNotifyMode --
  23.  *
  24.  *       MediaNotifyPos --
  25.  *
  26.  *       MediaNotifySize --
  27.  *
  28.  *************************************************************************/
  29.  
  30. #ifndef _WMEDIA_HPP_INCLUDED
  31. #define _WMEDIA_HPP_INCLUDED
  32.  
  33. #ifndef _WNO_PRAGMA_PUSH
  34. #pragma pack(push,8);
  35. #pragma enum int;
  36. #endif
  37.  
  38. #ifndef _WCONTROL_HPP_INCLUDED
  39. #  include "wcontrol.hpp"
  40. #endif
  41.  
  42. #ifndef _WFILPATH_HPP_INCLUDED
  43. #  include "wfilpath.hpp"
  44. #endif
  45.  
  46. #ifdef _UNICODE
  47. #define WMPNotifyMedia              WMPNotifyMediaUnicode
  48. #else
  49. #define WMPNotifyMedia              WMPNotifyMediaAnsi
  50. #endif
  51.  
  52. //
  53. // MediaPlayer styles
  54. //
  55.  
  56. #define WMPNoAutoSizeWindow         ((WStyle)0x00000001) // MCIWNDF_NOAUTOSIZEWINDOW
  57. #define WMPNoPlayBar                ((WStyle)0x00000002) // MCIWNDF_NOPLAYBAR
  58. #define WMPNoAutoSizeMovie          ((WStyle)0x00000004) // MCIWNDF_NOAUTOSIZEMOVIE
  59. #define WMPNoMenu                   ((WStyle)0x00000008) // MCIWNDF_NOMENU
  60. #define WMPShowName                 ((WStyle)0x00000010) // MCIWNDF_SHOWNAME
  61. #define WMPShowPos                  ((WStyle)0x00000020) // MCIWNDF_SHOWPOS
  62. #define WMPShowMode                 ((WStyle)0x00000040) // MCIWNDF_SHOWMODE
  63. #define WMPShowAll                  ((WStyle)0x00000070) // MCIWNDF_SHOWALL
  64. #define WMPNotifyAnsi               ((WStyle)0x00000080) // MCIWNDF_NOTIFYANSI
  65. #define WMPNotifyMode               ((WStyle)0x00000100) // MCIWNDF_NOTIFYMODE
  66. #define WMPNotifyPos                ((WStyle)0x00000200) // MCIWNDF_NOTIFYPOS
  67. #define WMPNotifySize               ((WStyle)0x00000400) // MCIWNDF_NOTIFYSIZE
  68. #define WMPNotifyError              ((WStyle)0x00001000) // MCIWNDF_NOTIFYERROR
  69. #define WMPNotifyAll                ((WStyle)0x00001F00) // MCIWNDF_NOTIFYALL
  70. #define WMPNotifyMediaAnsi          ((WStyle)0x00000880) // MCIWNDF_NOTIFYMEDIAA
  71. #define WMPNotifyMediaUnicode       ((WStyle)0x00000800) // MCIWNDF_NOTIFYMEDIAW
  72. #define WMPRecord                   ((WStyle)0x00002000) // MCIWNDF_RECORD
  73. #define WMPNoErrorDlg               ((WStyle)0x00004000) // MCIWNDF_NOERRORDLG
  74. #define WMPNoOpen                   ((WStyle)0x00008000) // MCIWNDF_NOOPEN
  75.  
  76. #ifdef _UNICODE
  77. #define WMPDefault                  ((WStyle)0x50001F51L) // WS_VISIBLE|WS_CHILD|MCIWNDF_SHOWALL|MCIWNDF_NOAUTOSIZEWINDOW|MCIWNDF_NOTIFYALL|MCIWNDF_NOTIFYMEDIAW
  78. #else
  79. #define WMPDefault                  ((WStyle)0x50001FF1L) // WS_VISIBLE|WS_CHILD|MCIWNDF_SHOWALL|MCIWNDF_NOAUTOSIZEWINDOW|MCIWNDF_NOTIFYALL|MCIWNDF_NOTIFYMEDIAA
  80. #endif
  81. #define WMPDefaultOld               (((WStyle)0x50001F71L)|WMPNotifyMedia) // WS_VISIBLE|WS_CHILD|MCIWNDF_SHOWALL|MCIWNDF_NOAUTOSIZEWINDOW|MCIWNDF_NOTIFYALL|MCIWNDF_NOTIFYMEDIA
  82.  
  83. struct WMediaNotifyEventData : WEventData {
  84.    WChar* fileName;
  85.    WLong  lData;
  86. };
  87.  
  88. class WCMCLASS WMediaPlayer : public WControl {
  89.     WDeclareSubclass( WMediaPlayer, WControl );
  90.  
  91.     public:
  92.  
  93.         WMediaPlayer();
  94.  
  95.         ~WMediaPlayer();
  96.  
  97.         /*******************************************************************
  98.          * Properties
  99.          *******************************************************************/
  100.  
  101.         // CanEject
  102.  
  103.         WBool GetCanEject();
  104.  
  105.         // CanPlay
  106.  
  107.         WBool GetCanPlay();
  108.  
  109.         // CanRecord
  110.  
  111.         WBool GetCanRecord();
  112.  
  113.         // CanSave
  114.  
  115.         WBool GetCanSave();
  116.  
  117.         // Position
  118.  
  119.         #define WMEDIAPLAYER_SEEK_HOME          -1
  120.         #define WMEDIAPLAYER_SEEK_START         -1
  121.         #define WMEDIAPLAYER_SEEK_END           -2
  122.  
  123.         WBool SetPosition( WLong position );
  124.         WLong GetPosition();
  125.  
  126.         // Repeat
  127.  
  128.         WBool GetRepeat();
  129.         WBool SetRepeat( WBool repeat );
  130.  
  131.         // Speed
  132.  
  133.         WUInt GetSpeed();
  134.         WBool SetSpeed( WUInt speed=1000 );
  135.  
  136.         // Volume
  137.  
  138.         WUInt GetVolume();
  139.         WBool SetVolume( WUInt volume=1000 );
  140.  
  141.         // Zoom
  142.  
  143.         WUInt GetZoom();
  144.         WBool SetZoom( WUInt zoom=100 );
  145.  
  146.         /*******************************************************************
  147.          * Methods
  148.          *******************************************************************/
  149.  
  150.         // Close
  151.  
  152.         WBool Close();
  153.  
  154.         // Eject
  155.  
  156.         WBool Eject();
  157.  
  158.         // New
  159.  
  160.         WBool New( const WFilePath & fileName );
  161.  
  162.         // Open
  163.         //
  164.         //      The parameterless version invokes an open dialog
  165.  
  166.         WBool Open();
  167.         WBool Open( const WFilePath & fileName, WBool createIfDoesntExist=FALSE );
  168.  
  169.         // Pause
  170.  
  171.         WBool Pause();
  172.  
  173.         // Play
  174.  
  175.         WBool Play( WLong from=WMEDIAPLAYER_SEEK_START,
  176.                     WLong to=WMEDIAPLAYER_SEEK_END );
  177.  
  178.         // Record
  179.  
  180.         WBool Record();
  181.  
  182.         // Resume
  183.  
  184.         WBool Resume();
  185.  
  186.         // Save
  187.         //
  188.         //      The parameterless version invokes a save dialog
  189.  
  190.         WBool Save();
  191.         WBool Save( const WFilePath & fileName );
  192.  
  193.         // Step
  194.  
  195.         WBool Step( WLong increment );
  196.  
  197.         // Stop
  198.  
  199.         WBool Stop();
  200.  
  201.         /*******************************************************************
  202.          * Overrides
  203.          *******************************************************************/
  204.  
  205.         virtual WBool Destroy();
  206.  
  207.         virtual WBool ProcessMessage( const WMessage & msg,
  208.                                       WLong & returns );
  209.     
  210.         virtual const WChar * InitializeClass();
  211.  
  212.         virtual WStyle GetDefaultStyle() const;
  213.  
  214.         virtual WStyle GetDefaultExtendedStyle() const;
  215.  
  216.         virtual WBool CloneWindow( WStyle newStyle, WStyle newExStyle,
  217.                                    void * data=NULL );
  218. };
  219.  
  220. #ifndef _INC_MMSYSTEM
  221. #ifndef _MCIDEVICEID_           /* Same with MCIDEVICEID */
  222. #define _MCIDEVICEID_
  223. typedef WUInt    MCIDEVICEID;    /* MCI device ID type */
  224. #endif
  225. #define MCI_STRING_OFFSET      512
  226. #endif
  227.  
  228. typedef MCIDEVICEID     WMediaDeviceID;
  229.  
  230. enum WMediaDeviceOpenFlags {
  231.     WMediaDeviceOpenShareable   = 0x00000100L,
  232.     WMediaDeviceOpenElement     = 0x00000200L,
  233.     WMediaDeviceOpenAlias       = 0x00000400L,
  234.     WMediaDeviceOpenElementID   = 0x00000800L,
  235.     WMediaDeviceOpenTypeID      = 0x00001000L,
  236.     WMediaDeviceOpenType        = 0x00002000L,
  237. };
  238.  
  239. enum WMediaDevicePlayFlags {
  240.     WMediaDevicePlayFrom        = 0x00000004L,
  241.     WMediaDevicePlayTo          = 0x00000008L,
  242. };
  243.  
  244. enum WMediaDeviceSeekFlags {
  245.     WMediaDeviceSeekTo          = 0x00000008L,
  246.     WMediaDeviceSeekToStart     = 0x00000100L,
  247.     WMediaDeviceSeekToEnd       = 0x00000200L,
  248. };
  249.  
  250. enum WMediaDeviceTimeFormat {
  251.     WMediaDeviceTimeFormatMilliseconds  = 0,
  252.     WMediaDeviceTimeFormatHMS           = 1,
  253.     WMediaDeviceTimeFormatMSF           = 2,
  254.     WMediaDeviceTimeFormatFrames        = 3,
  255.     WMediaDeviceTimeFormatSMPTE_24      = 4,
  256.     WMediaDeviceTimeFormatSMPTE_25      = 5,
  257.     WMediaDeviceTimeFormatSMPTE_30      = 6,
  258.     WMediaDeviceTimeFormatSMPTE_30DROP  = 7,
  259.     WMediaDeviceTimeFormatBytes         = 8,
  260.     WMediaDeviceTimeFormatSamples       = 9,
  261.     WMediaDeviceTimeFormatTMSF          = 10,
  262. };
  263.  
  264. enum WMediaDeviceMode {
  265.     WMediaDeviceModeNotReady    = (MCI_STRING_OFFSET + 12),
  266.     WMediaDeviceModeStop        = (MCI_STRING_OFFSET + 13),
  267.     WMediaDeviceModePlay        = (MCI_STRING_OFFSET + 14),
  268.     WMediaDeviceModeRecord      = (MCI_STRING_OFFSET + 15),
  269.     WMediaDeviceModeSeek        = (MCI_STRING_OFFSET + 16),
  270.     WMediaDeviceModePause       = (MCI_STRING_OFFSET + 17),
  271.     WMediaDeviceModeOpen        = (MCI_STRING_OFFSET + 18),
  272. };
  273.  
  274. class WCMCLASS WMediaDevice : public WObject {
  275.     WDeclareSubclass( WMediaDevice, WObject );
  276.  
  277.     public:
  278.  
  279.         /*******************************************************************
  280.          * Constructors and Destructors
  281.          *******************************************************************/
  282.  
  283.         WMediaDevice();
  284.  
  285.         ~WMediaDevice();
  286.  
  287.         /*******************************************************************
  288.          * Properties
  289.          *******************************************************************/
  290.  
  291.         // CurrentTrack
  292.  
  293.         WULong GetCurrentTrack() const;
  294.  
  295.         // DoorOpened
  296.  
  297.         WBool SetDoorOpened( WBool doorOpened );
  298.  
  299.         // ID
  300.  
  301.         WMediaDeviceID GetID() const;
  302.  
  303.         // Length
  304.  
  305.         WULong GetLength() const;
  306.  
  307.         // Mode
  308.  
  309.         WMediaDeviceMode GetMode() const;
  310.  
  311.         // Position
  312.  
  313.         WULong GetPosition() const;
  314.  
  315.         // Ready
  316.  
  317.         WBool GetReady() const;
  318.  
  319.         // TimeFormat
  320.  
  321.         WMediaDeviceTimeFormat GetTimeFormat() const;
  322.         WBool SetTimeFormat( WMediaDeviceTimeFormat format );
  323.  
  324.         // TrackCount
  325.  
  326.         WULong GetTrackCount() const;
  327.  
  328.         /*******************************************************************
  329.          * Methods
  330.          *******************************************************************/
  331.  
  332.         // Close
  333.  
  334.         WBool Close( WBool wait=FALSE );
  335.  
  336.         // Open
  337.  
  338.         WBool Open( const WChar * deviceType,
  339.                     WMediaDeviceOpenFlags flags=WMediaDeviceOpenType,
  340.                     const WChar * elementName=NULL,
  341.                     const WChar * deviceAlias=NULL, WBool wait=FALSE );
  342.  
  343.         // Pause
  344.  
  345.         WBool Pause( WBool wait=FALSE );
  346.  
  347.         // Play
  348.  
  349.         WBool Play( WULong flags=0, WULong from=0, WULong to=0,
  350.                     WBool wait=FALSE );
  351.  
  352.         // Seek
  353.  
  354.         WBool Seek( WMediaDeviceSeekFlags flags, WULong seekTo,
  355.                     WBool wait=FALSE );
  356.  
  357.         // SendCommand
  358.  
  359.         WBool SendCommand( WUInt message, WDWord flags, void * info );
  360.  
  361.         // Stop
  362.  
  363.         WBool Stop( WBool wait=FALSE );
  364.  
  365.         /*******************************************************************
  366.          * Item Properties
  367.          *******************************************************************/
  368.  
  369.         // Length
  370.  
  371.         WULong GetLength( WULong track ) const;
  372.  
  373.         // Position
  374.  
  375.         WULong GetPosition( WULong track ) const;
  376.  
  377.         /*******************************************************************
  378.          * Data Members
  379.          *******************************************************************/
  380.  
  381.     private:
  382.  
  383.         WMediaDeviceID          _id;
  384. };
  385.  
  386. #ifndef _WNO_PRAGMA_PUSH
  387. #pragma enum pop;
  388. #pragma pack(pop);
  389. #endif
  390.  
  391. #endif // _WMEDIA_HPP_INCLUDED
  392.