PHP & JavaScript Room :: 設置サンプル

実行結果

ソース

<script type="text/javascript">
    /**
     * [関数名] qtAudioOpen
     * [機 能] 音声ファイルを小窓を開いて再生する(閉じるボタン付)
     * [引 数]
     * @param SoundTitle String 音声ファイルのタイトル
     * @param FilePass String 音声ファイルへのパス(相対 or 絶対パス)
     * [返り値]
     * @return htm String 生成されたHTML文
    */
    function qtAudioOpen(SoundTitle,FilePass) {
        PlayWin = window.open('','sample','width=350,height=170,top=0,left=0,resizable=0,status=1,scrollbars=0,titlebar=0,toolbar=0,menubar=0,directories=0,personalbar=0');
        PlayWin.focus();

        var htm="";
        htm+="<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n";
        htm+="<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='ja' lang='ja'>\n";
        htm+="<head>\n";
        htm+="<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\n";
        htm+="<meta http-equiv='Content-Script-Type' content='text/javascript'>\n";
        htm+="<meta http-equiv='content-style-type' content='text/css' />\n";
        htm+="<title>" + SoundTitle + "<\/title>\n";
        htm+="<\/head>\n";
        htm+="<bod";
        htm+="y style='background:#f7f7f7 url(/content/img/bg/slash_gray.png) repeat top left; margin:0; padding:0;'>\n";
        htm+="<p style='color:#696969; font:normal bold 20px Century,\"Lucida Sans Unicode\",geneva,verdana,sans-serif; text-align:center; padding-top:1em;'>" + SoundTitle + "<\/p>\n";
        htm+="<p style='text-align:center;'>\n";

        /* Windows Media Player 音声埋め込み [begin] */
        htm+="<object id='WMP' width='320' height='45' classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715' standby='Loading Microsoft Windows Media Player components...' type='audio/x-ms-wma'>\n";
        htm+="<param name='FileName' value='"+FilePass+"' />\n";
        htm+="<param name='AutoStart' value='true' />\n";
        htm+="<param name='ShowControls' value='true' />\n";
        htm+="<embed name='WMP' pluginspage='http://www.microsoft.com/Windows/MediaPlayer/' type='application/x-mplayer2' src='"+FilePass+"' width='320' height='45' autostart='1' showcontrols='1'>\n";
        htm+="<\/embed>\n";
        htm+="<\/object>\n";
        /* Windows Media Player 音声埋め込み [end//] */

        htm+="<\/p>\n";
        htm+="<form action='#'><div align='center'><input type='image' alt='閉じる' width='69' height='20' src='/content/img/btn/close.gif' onclick='javascript:self.close();'><\/div><\/form>\n";
        htm+="<\/bod";
        htm+="y>\n";
        htm+="<\/html>\n";

        PlayWin.document.write(htm);
        PlayWin.document.close();
    }
</script>

<form action="#">
    <input type="button" onclick="qtAudioOpen('SampleMusic','/content/media/sample.wma');" value="サンプル曲を小窓を開いて再生" />
</form>

polarized women