audiorecorder.inc.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Created on 27.09.2006
  5. * Include the lazlo file necessary to use the audiorecorder
  6. * @author Sebastian Wagner <seba.wagner@gmail.com>
  7. * @author Eric Marguin <e.marguin@elixir-interactive.com>
  8. * @author Arnaud Ligot <arnaud@cblue.be>
  9. * @package chamilo.learnpath
  10. */
  11. $web_path = api_get_path(WEB_CODE_PATH);
  12. $getid3_path = api_get_path(LIBRARY_PATH);
  13. require_once $getid3_path.'getid3/getid3.php';
  14. function getFLVDuration($flv_path) {
  15. $getid3 = new getID3;
  16. $getid3->encoding = 'UTF-8';
  17. try {
  18. $getid3->Analyze($flv_path);
  19. return $getid3->info['playtime_seconds'];
  20. } catch (Exception $e) {
  21. return 0;
  22. }
  23. }
  24. $course_id = api_get_course_int_id();
  25. if ($audio_recorder_studentview == 'false') {
  26. $width = 295;
  27. $height= 90;
  28. $player = 'recorder2.swf';
  29. $server = (api_get_setting('service_visio', 'visio_use_rtmpt') == 'true' ? 'rtmpt://' : 'rtmp://').api_get_setting('service_visio', 'visio_host').':'.(api_get_setting('service_visio', 'visio_use_rtmpt') == 'true' ? '80' : api_get_setting('service_visio', 'visio_port')).'/recorder';
  30. $post_uri = urlencode($web_path.'conference/audiopost.php?course_code='.api_get_course_id().'&user_id='.api_get_user_id().'&checker='.md5(api_get_course_id().api_get_user_id().gmdate('Ymd')));
  31. $filename = 'lpi'.$audio_recorder_item_id.'-'.gmdate('YmdHis').api_get_user_id().'.flv'; // Using -z- as fields splitter.
  32. $path_to_lzx = $web_path.'conference/'.$player.'?server='.urlencode($server).'&postURI='.$post_uri.'&filename='.$filename;
  33. } else {
  34. $width = 295;
  35. $height = 24;
  36. $player = 'player2.swf';
  37. $cp = api_get_course_path();
  38. $docs = Database::get_course_table(TABLE_DOCUMENT);
  39. $select = "SELECT * FROM $docs " .
  40. " WHERE c_id = $course_id AND path like BINARY '/audio/lpi".intval($audio_recorder_item_id)."-%' AND filetype='file' " .
  41. " ORDER BY path DESC";
  42. $res = Database::query($select);
  43. if (Database::num_rows($res) > 0) {
  44. $row = Database::fetch_array($res);
  45. //$filepath = api_get_path(WEB_COURSE_PATH).$cp.'/document'.$row['path'];
  46. $duration = getFLVDuration(api_get_path(SYS_COURSE_PATH).$cp.'/document'.$row['path']);
  47. $filepath = api_get_path(WEB_CODE_PATH).'document/download.php?'.api_get_cidreq().'&doc_url='.$row['path'];
  48. $path_to_lzx = $web_path.'conference/'.$player.'?uri='.urlencode($filepath).'&autostart=true&duration='.$duration;
  49. }
  50. }
  51. if (!empty($path_to_lzx)) {
  52. $recorder_content = sprintf("<object type=\"application/x-shockwave-flash\" data=\"%s\" ".
  53. "width='$width' height='$height'>".
  54. "<param name=\"movie\" value=\"%s\">".
  55. "<param name=\"quality\" value=\"high\">".
  56. "<param name=\"scale\" value=\"noscale\">".
  57. "<param name=\"salign\" value=\"LT\">".
  58. "<param name=\"menu\" value=\"false\"></object>", $path_to_lzx, $path_to_lzx);
  59. if ($audio_recorder_studentview == 'false') {
  60. echo '<script type="text/javascript">
  61. function show_audiorecorder() {
  62. document.getElementById("audiorecorder_frame").innerHTML = "'.addslashes($recorder_content).'";
  63. document.getElementById("show_audiorecorder_div").style.display="none";
  64. }
  65. </script>';
  66. // Commented the audio for the version stable.
  67. //echo '<div id="show_audiorecorder_div"><a style="cursor:pointer" onclick="show_audiorecorder()">'.get_lang('ShowAudioRecorder').'</a></div>';
  68. //echo '<div id="audiorecorder_frame"></div>';
  69. } else {
  70. echo $recorder_content;
  71. }
  72. }