I'm not yet seeing the need for a class. Here's a function to try:<?php
# rg_Play.php ver 1.0
# Ref: http://my.noteworthysoftware.com/?topic=8312.0
require_once('lib/nwc2clips.inc');
$wso = new COM('WScript.Shell');
$a = array('|Clef|Type:Alto', '|Note', '|Note|Pos:2', '|Note|Dur:Whole|Pos:3');
$clip = new NWC2Clip();
$list = array($a, $clip->Items);
$opt = -1;
while (isset($list[++$opt])) {
$control = Play($list[$opt]);
switch ($wso->Popup('Repeat?', 0, $argv[0], 35)) {
case 2: $opt = -10; // Cancel
case 6: $opt--; // Yes
}
unset($control); // stops playback and releases file
}
$stat = fstat(STDOUT); if ($stat['size']) exit(NWC2RC_REPORT);
function Play($items) {
$opt = array('bypass_shell' => true);
$cmd = array('nwc-conv', 'NWCTXT', sys_get_temp_dir().'_rg_.mid');
if (!is_file($cmd[2])) register_shutdown_function('unlink', $cmd[2]);
rewind(STDIN); // aka 'php://stdin'
preg_match('/\d+\.\d+/', current(preg_grep('/^!/', gzfile('php://stdin'))), $m);
fwrite($h = tmpfile(), NWC2_STARTFILETXT.'('.$m[0].')'.PHP_EOL); // header
fwrite($h, join(PHP_EOL, $items));
fwrite($h, NWC2_STARTFILETXT.PHP_EOL); rewind($h); // footer
proc_open(join(' ', $cmd), array($h), $x, null, null, $opt);
$wmp = new COM('WMPlayer.ocx');
$wmp->URL = $cmd[2];
return $wmp;
}
?>