--*************************************************************************
-- Script: AVMedia Xtra wrapper for Windows
-- Version: 0.1-alpha
-- Author: Valentin Schmidt
--
-- Requirements/Dependencies:
-- * DirectShow Xtra (http://valentin.dasdeck.com/xtras/directshow_xtra/)
--
--*************************************************************************
property _DS
on new me
_DS = xtra("DirectShow").new()
return me
end
-- #####################################
-- Audio
-- #####################################
-- audioOpen object me, any pathOrURLOrData, *allowRateChange, fileTypeHint
on audioOpen (me, pathOrURLOrData, allowRateChange, fileTypeHint)
props = [:]
props["registergraph"] = 1
props["mediafile"] = pathOrURLOrData
hr = _DS.ds_open(props)
end
-- audioClose object me
on audioClose (me)
_DS.ds_stop()
_DS.ds_close()
end
-- audioPlay object me
on audioPlay (me)
_DS.ds_play()
end
-- audioPause object me
on audioPause (me)
_DS.ds_pause()
end
--audioGetDuration object me
on audioGetDuration (me)
info = _DS.ds_get_media_info()
return info["duration"]
end
--audioGetCurrentTime object me
on audioGetCurrentTime (me)
return _DS.ds_get_param ("time")
end
--audioSetCurrentTime object me, integer timeMS
on audioSetCurrentTime (me, timeMS)
_DS.ds_set_param(["time":timeMS])
end
--audioGetPan object me
-- MS: integer balance
-- Specifies the balance. The value can range from
-- - 10,000 to 10,000.
on audioGetPan (me)
return _DS.ds_get_param("balance")
end
--audioSetPan object me, float pan
on audioSetPan (me, pan)
_DS.ds_set_param(["balance":pan])
end
--audioGetRate object me
on audioGetRate (me)
return _DS.ds_get_param("rate")
end
--audioSetRate object me, float rate
on audioSetRate (me, rate)
_DS.ds_set_param(["rate":rate])
end
--audioGetVolume object me
on audioGetVolume (me)
return _DS.ds_get_param("volume")
end
--audioSetVolume object me, float volume
on audioSetVolume (me, volume)
_DS.ds_set_param(["volume":volume])
end
-- #####################################
-- MIDI
-- #####################################
--midiOpen object me, any pathOrURLOrData, *soundbankPath
on midiOpen (me, pathOrURLOrData)
props = [:]
props["registergraph"] = 1
props["mediafile"] = pathOrURLOrData
hr = _DS.ds_open(props)
end
--midiClose object me
on midiClose (me)
_DS.ds_stop()
_DS.ds_close()
end
--midiPlay object me
on midiPlay (me)
_DS.ds_play()
end
--midiPause object me
on midiPause (me)
_DS.ds_pause()
end
--midiGetDuration object me
on midiGetDuration (me)
info = _DS.ds_get_media_info()
return info["duration"]
end
--midiGetCurrentTime object me
on midiGetCurrentTime (me)
return _DS.ds_get_param ("time")
end
--midiSetCurrentTime object me, integer timeMS
on midiSetCurrentTime (me, timeMS)
_DS.ds_set_param(["time":timeMS])
end
-- #####################################
-- VIDEO
-- #####################################
--videoOpen object me, string pathOrURL, object rect, *windowMask, overlayImageFile
on videoOpen (me, pathOrURL, playRect, windowMask, overlayImageFile)
props = [:]
props["registergraph"] = 1
props["mediafile"] = pathOrURL
props["paused"] = 1
props["hwnd"] = 0
props["rect"] = playRect
hr = _DS.ds_open(props)
end
--videoClose object me
on videoClose (me)
_DS.ds_stop()
_DS.ds_close()
end
--videoGetDuration object me
on videoGetDuration (me)
info = _DS.ds_get_media_info()
return info["duration"]
end
--videoGetCurrentTime object me
on videoGetCurrentTime (me)
return _DS.ds_get_param ("time")
end
--videoSetCurrentTime object me, integer timeMS
on videoSetCurrentTime (me, timeMS)
_DS.ds_set_param(["time":timeMS])
end
--videoGetRate object me
on videoGetRate (me)
return _DS.ds_get_param("rate")
end
--videoSetRate object me, float rate
on videoSetRate (me, rate)
_DS.ds_set_param(["rate":rate])
end
--videoGetVolume object me
on videoGetVolume (me)
return _DS.ds_get_param("volume")
end
--videoSetVolume object me, float volume
on videoSetVolume (me, volume)
_DS.ds_set_param(["volume":volume])
end
--videoStepByCount object me, integer stepCount
on videoStepByCount (me, stepCount)
if stepCount>=0 then
_DS.ds_step_forward(stepCount)
else
_DS.ds_step_backwards(-stepCount)
end if
end