1. --*************************************************************************
  2. -- Script:   AVMedia Xtra wrapper for Windows
  3. -- Version:  0.1-alpha
  4. -- Author:   Valentin Schmidt
  5. --
  6. -- Requirements/Dependencies:
  7. -- * DirectShow Xtra (http://valentin.dasdeck.com/xtras/directshow_xtra/)
  8. --
  9. --*************************************************************************
  10.  
  11. property _DS
  12.  
  13. on new me
  14.   _DS = xtra("DirectShow").new()
  15.   return me
  16. end
  17.  
  18. -- #####################################
  19. -- Audio
  20. -- #####################################
  21.  
  22. -- audioOpen object me, any pathOrURLOrData, *allowRateChange, fileTypeHint
  23. on audioOpen (me, pathOrURLOrData, allowRateChange, fileTypeHint)  
  24.   props = [:]
  25.   props["registergraph"] = 1  
  26.   props["mediafile"] = pathOrURLOrData
  27.   hr = _DS.ds_open(props)
  28. end
  29.  
  30. -- audioClose object me
  31. on audioClose (me)
  32.   _DS.ds_stop()
  33.   _DS.ds_close()
  34. end
  35.  
  36. -- audioPlay object me
  37. on audioPlay (me)
  38.   _DS.ds_play()
  39. end
  40.  
  41. -- audioPause object me
  42. on audioPause (me)
  43.   _DS.ds_pause()
  44. end
  45.  
  46. --audioGetDuration object me
  47. on audioGetDuration (me)
  48.   info = _DS.ds_get_media_info()
  49.   return info["duration"]
  50. end
  51.  
  52. --audioGetCurrentTime object me
  53. on audioGetCurrentTime (me)
  54.   return _DS.ds_get_param ("time")
  55. end
  56.  
  57. --audioSetCurrentTime object me, integer timeMS
  58. on audioSetCurrentTime (me, timeMS)
  59.   _DS.ds_set_param(["time":timeMS])
  60. end
  61.  
  62. --audioGetPan object me
  63. -- MS: integer balance    
  64. -- Specifies the balance. The value can range from
  65. -- - 10,000 to 10,000.
  66. on audioGetPan (me)
  67.   return _DS.ds_get_param("balance")
  68. end
  69.  
  70. --audioSetPan object me, float pan
  71. on audioSetPan (me, pan)
  72.   _DS.ds_set_param(["balance":pan])
  73. end
  74.  
  75. --audioGetRate object me
  76. on audioGetRate (me)
  77.   return _DS.ds_get_param("rate")
  78. end
  79.  
  80. --audioSetRate object me, float rate
  81. on audioSetRate (me, rate)
  82.   _DS.ds_set_param(["rate":rate])
  83. end
  84.  
  85. --audioGetVolume object me
  86. on audioGetVolume (me)
  87.   return _DS.ds_get_param("volume")
  88. end
  89.  
  90. --audioSetVolume object me, float volume
  91. on audioSetVolume (me, volume)
  92.   _DS.ds_set_param(["volume":volume])
  93. end
  94.  
  95. -- #####################################
  96. -- MIDI
  97. -- #####################################
  98.  
  99. --midiOpen object me, any pathOrURLOrData, *soundbankPath
  100. on midiOpen (me, pathOrURLOrData)
  101.   props = [:]
  102.   props["registergraph"] = 1  
  103.   props["mediafile"] = pathOrURLOrData
  104.   hr = _DS.ds_open(props)
  105. end
  106.  
  107. --midiClose object me
  108. on midiClose (me)
  109.   _DS.ds_stop()
  110.   _DS.ds_close()
  111. end
  112.  
  113. --midiPlay object me
  114. on midiPlay (me)
  115.   _DS.ds_play()
  116. end
  117.  
  118. --midiPause object me
  119. on midiPause (me)
  120.   _DS.ds_pause()
  121. end
  122.  
  123. --midiGetDuration object me
  124. on midiGetDuration (me)
  125.   info = _DS.ds_get_media_info()
  126.   return info["duration"]
  127. end
  128.  
  129. --midiGetCurrentTime object me
  130. on midiGetCurrentTime (me)
  131.   return _DS.ds_get_param ("time")
  132. end
  133.  
  134. --midiSetCurrentTime object me, integer timeMS
  135. on midiSetCurrentTime (me, timeMS)
  136.   _DS.ds_set_param(["time":timeMS])
  137. end
  138.  
  139. -- #####################################
  140. -- VIDEO
  141. -- #####################################
  142.  
  143. --videoOpen object me, string pathOrURL, object rect, *windowMask, overlayImageFile
  144. on videoOpen (me, pathOrURL, playRect, windowMask, overlayImageFile)  
  145.   props = [:]
  146.   props["registergraph"] = 1  
  147.   props["mediafile"] = pathOrURL
  148.   props["paused"] = 1
  149.   props["hwnd"] = 0
  150.   props["rect"] = playRect
  151.   hr = _DS.ds_open(props)
  152. end
  153.  
  154. --videoClose object me
  155. on videoClose (me)
  156.   _DS.ds_stop()
  157.   _DS.ds_close()
  158. end
  159.  
  160. --videoGetDuration object me
  161. on videoGetDuration (me)
  162.   info = _DS.ds_get_media_info()
  163.   return info["duration"]
  164. end
  165.  
  166. --videoGetCurrentTime object me
  167. on videoGetCurrentTime (me)
  168.   return _DS.ds_get_param ("time")
  169. end
  170.  
  171. --videoSetCurrentTime object me, integer timeMS
  172. on videoSetCurrentTime (me, timeMS)
  173.   _DS.ds_set_param(["time":timeMS])
  174. end
  175.  
  176. --videoGetRate object me
  177. on videoGetRate (me)
  178.   return _DS.ds_get_param("rate")
  179. end
  180.  
  181. --videoSetRate object me, float rate
  182. on videoSetRate (me, rate)
  183.   _DS.ds_set_param(["rate":rate])
  184. end
  185.  
  186. --videoGetVolume object me
  187. on videoGetVolume (me)
  188.   return _DS.ds_get_param("volume")
  189. end
  190.  
  191. --videoSetVolume object me, float volume
  192. on videoSetVolume (me, volume)
  193.   _DS.ds_set_param(["volume":volume])
  194. end
  195.  
  196. --videoStepByCount object me, integer stepCount
  197. on videoStepByCount (me, stepCount)
  198.   if stepCount>=0 then
  199.     _DS.ds_step_forward(stepCount)
  200.   else
  201.     _DS.ds_step_backwards(-stepCount)
  202.   end if
  203. end
  204.  
  205.  
[raw code]