function videoboard_player_mp3($link, $mime = 'audio/mp3', $ids = 0) { global $OUTPUT, $videoboard, $CFG; $player_html5 = ""; $player_html5 .= html_writer::start_tag('div', array("id" => "html5-player-" . $ids)); $player_html5 .= html_writer::start_tag('audio', array("id" => "html5-audioplayer-" . $ids, "controls" => "controls", "src" => $link)); $player_html5 .= html_writer::link($link, get_string("audio", "videoboard")); $player_html5 .= html_writer::end_tag('audio'); $player_html5 .= html_writer::end_tag('div'); $player_flash = ""; $player_flash .= html_writer::script('var fn = function() {var att = { data:"' . new moodle_url("/mod/videoboard/js/mp3player.swf") . '", width:"90", height:"15" };var par = { flashvars:"src=' . $link . '" };var id = "videoboard-player-' . $ids . '";var myObject = swfobject.createSWF(att, par, id);};swfobject.addDomLoadEvent(fn);'); $player_flash .= '<div id="videoboard-player-' . $ids . '"><a href="' . $link . '">audio</a></div>'; $browser = videoboard_get_browser(); if (videoboard_is_ios()) { return $player_html5; } else { if ($browser == 'firefox') { return $player_flash; } else { if ($browser == 'msie') { return $player_flash; } else { if ($browser == 'chrome') { return $player_flash; } else { return $player_html5; } } } } }
function definition() { global $CFG, $USER, $DB, $course, $fileid, $id, $act, $commentid; $time = time(); $filename = str_replace(" ", "_", $USER->username) . "_" . date("Ymd_Hi", $time); $mform =& $this->_form; $mform->updateAttributes(array('enctype' => 'multipart/form-data')); //--------------Uploadd MP3 ----------------// if (!videoboard_is_ios()) { $filepickeroptions = array(); //$filepickeroptions['filetypes'] = array('.mp3','.mov','.mp4','.m4a'); $filepickeroptions['maxbytes'] = get_max_upload_file_size($CFG->maxbytes); $mform->addElement('header', 'mp3upload', get_string('mp3upload', 'videoboard')); $mform->addElement('filepicker', 'submitfile', get_string('uploadmp3', 'videoboard'), null, $filepickeroptions); } $mform->addElement('header', 'addcomment', get_string('addcomment', 'videoboard')); $youtubeurl = ""; if (!empty($fileid) && empty($act)) { $data = $DB->get_record("videoboard_files", array("id" => $fileid, "userid" => $USER->id)); $mform->addElement('editor', 'summary', '')->setValue(array('text' => $data->summary)); $youtubeurl = $data->itemyoutube; } else { if (!empty($act) && !empty($commentid)) { $data = $DB->get_record("videoboard_comments", array("id" => $commentid, "userid" => $USER->id)); $mform->addElement('editor', 'summary', '')->setValue(array('text' => $data->summary)); $mform->addelEment('hidden', 'commentid', $commentid); } else { $mform->addElement('editor', 'summary', ''); } } //-------------- Record ----------------// $mediadatavoice = ""; $mediadatavideo = ""; if (videoboard_is_ios()) { $mediadatavoice .= html_writer::start_tag("h3", array("style" => "padding: 0 20px;")); //$mediadatavoice .= html_writer::start_tag("a", array("href" => 'videoboard://?link='.$CFG->wwwroot.'&id='.$id.'&cid='.$course->id.'&filename='.$filename.'&type=audio', // "onclick" => 'formsubmit(this.href)')); $mediadatavoice .= get_string('recordvoice', 'videoboard'); //$mediadatavoice .= html_writer::end_tag('a'); $mediadatavoice .= html_writer::end_tag('h3'); $mediadatavideo .= html_writer::empty_tag("input", array("type" => "file", "name" => "mov_video", "accept" => "video/*", "capture" => "camcorder")); $mediadatavoice .= html_writer::script('function formsubmit(link) {$(\'input[name=iphonelink]\').val(link);$(\'#mform1\').submit();}'); $mediadatavoice .= html_writer::start_tag('div'); $mediadatavoice .= html_writer::empty_tag("input", array("type" => "file", "name" => "mobile_audio", "accept" => "audio/*", "capture" => "microphone")); $mediadatavoice .= html_writer::end_tag('div'); } else { if (videoboard_get_browser() == 'android') { $mediadatavideo .= html_writer::empty_tag("input", array("type" => "file", "name" => "mov_video", "accept" => "video/*", "capture" => "camcorder")); $mediadatavoice .= html_writer::empty_tag("input", array("type" => "file", "name" => "mobile_audio", "accept" => "audio/*", "capture" => "microphone")); } else { /* $mediadatavoice .= html_writer::start_tag("applet", array("id" => "nanogong", "archive" => "nanogong.jar", "code" => "gong.NanoGong", "width" => "180", "height" => "40")); $mediadatavoice .= html_writer::empty_tag("param", array("name" => "Color", "value" => "#ffffff")); $mediadatavoice .= html_writer::empty_tag("param", array("name" => "AudioFormat", "value" => "ImaADPCM")); $mediadatavoice .= html_writer::end_tag('applet'); $mediadatavoice .= html_writer::script(' $(document).ready(function() { $(\'#id_submitbutton\').click(function() {$(\'.loaderlayer\').show();}); $(\'#mform1\').live("submit", function(){$(\'.loaderlayer\').show();var applet = document.getElementById("nanogong");var ret = applet.sendGongRequest("PostToForm", "nanogong.php?userid='.$USER->id.'&id='.$id.'&filename='.$filename.'&fid="+$(\'#id_submitfile\').attr(\'value\'), "voicefile","", "temp");}); });'); $mediadatavoice .= html_writer::start_tag("div", array("class" => "loaderlayer", "style" => "display:none;background-color:#FF0000;position:fixed;right:0px;top:0px")); $mediadatavoice .= html_writer::empty_tag("img", array("src" => new moodle_url('/mod/videoboard/img/ajax-record-save.gif'), "alt" => get_string("recordsaved", "videoboard"))); $mediadatavoice .= html_writer::end_tag('div'); */ //$mediadatavoice .= html_writer::script('var fn = function() {var att = { data:"'.(new moodle_url("/mod/videoboard/swf/PoodllMP3Record.swf")).'", width:"350", height:"200"};var par = { flashvars:"rate=44&gain=50&prefdevice=&loopback=no&echosupression=yes&silencelevel=0&updatecontrol=poodll_recorded_file&callbackjs=poodllcallback&posturl='.(new moodle_url("/mod/videoboard/uploadmp3.php")).'&p1='.$id.'&p2='.$USER->id.'&p3="+$(\'#id_submitfile\').attr(\'value\')+"&p4='.$filename.'&autosubmit=true&debug=false&lzproxied=false" };var id = "mp3_flash_recorder";var myObject = swfobject.createSWF(att, par, id);};swfobject.addDomLoadEvent(fn);function poodllcallback(args){console.log(args);}'); //$mediadatavoice .= '<div id="mp3_flash_recorder"></div>'; $mediadatavoice .= html_writer::script('var flashvars={};flashvars.gain=35;flashvars.rate=44;flashvars.call="callbackjs";flashvars.name = "' . $filename . '";flashvars.p = "' . urlencode(json_encode(array("id" => $id, "userid" => $USER->id))) . '";flashvars.url = "' . urlencode(new moodle_url("/mod/videoboard/uploadmp3.php")) . '";swfobject.embedSWF("' . new moodle_url("/mod/videoboard/swf/recorder.swf") . '", "mp3_flash_recorder", "220", "200", "9.0.0", "expressInstall.swf", flashvars);'); $mediadatavoice .= '<div id="mp3_flash_recorder"></div><div id="mp3_flash_records" style="margin:20px 0;"></div>'; echo html_writer::script(' function chooserecord(e){ $(".choosingrecord").html(\'<img src="' . new moodle_url("/mod/videoboard/img/right-arrow-gray.png") . '" style="margin-top: 6px;"/>\'); $(e).html(\'<img src="' . new moodle_url("/mod/videoboard/img/right-arrow.png") . '" style="margin-top: 6px;"/>\'); $("#id_submitfile").val($(e).attr("data-url")); $("#id_speechtext").val($(e).attr("data-text")); } function callbackjs(e){ $("#id_speechtext").val(""+e.text+""); $(".choosingrecord").html(\'<img src="' . new moodle_url("/mod/videoboard/img/right-arrow-gray.png") . '" style="margin-top: 6px;"/>\'); obj = JSON.parse(e.data); $("#mp3_flash_records").prepend(\'<div class="recordings"><div class="choosingrecord" style="float:left;cursor: pointer;" data-url="\'+obj.id+\'" data-text="\'+e.text+\'" onclick="chooserecord(this)"><img src="' . new moodle_url("/mod/videoboard/img/right-arrow.png") . '" style="margin-top: 6px;"/></div><div style="float:left;"><div><audio controls id="peviewaudio" oncanplay="this.volume=0.5"><source src="' . $CFG->wwwroot . '\'+obj.url+\'" preload="auto" type="audio/mpeg"></audio></div></div><div style="clear:both;"></div></div>\'); $("#id_submitfile").val(obj.id); if($("#mp3_flash_records > div").size() >= ' . (3 + 1) . ') { $("#mp3_flash_records > div").last().remove(); } } '); } } $mform->addElement('header', 'Recording', get_string('recordvoice', 'videoboard')); $mform->addelEment('hidden', 'filename', $filename); $mform->addelEment('hidden', 'iphonelink', ''); $mform->addElement('static', 'description', '', $mediadatavoice); if (!empty($mediadatavideo)) { $mform->addElement('header', 'Recording', get_string('recordvideo', 'videoboard')); $mform->addElement('static', 'description', '', $mediadatavideo); } if (!empty($fileid) && empty($act)) { $mform->setDefault("filename", $data->filename); $mform->addelEment('hidden', 'fileid', $fileid); } if (!empty($act)) { $mform->addelEment('hidden', 'act', $act); $mform->addelEment('hidden', 'fileid', $fileid); } else { $mform->addelEment('hidden', 'act', 'newinstance'); } //-------------- Record -------END------// $mform->addElement('header', 'youtubevideo_header', get_string('youtubevideo', 'videoboard')); $mform->addElement('textarea', 'itemyoutube', '', 'wrap="virtual" rows="5" cols="100"')->setValue($youtubeurl); $this->add_action_buttons(false, $submitlabel = get_string("saverecording", "videoboard")); }