audiorecorder.inc.php 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. global $_configuration;
  12. $web_path = api_get_path(WEB_CODE_PATH);
  13. $getid3_path = api_get_path(LIBRARY_PATH);
  14. require_once $getid3_path.'getid3/getid3.php';
  15. function getFLVDuration($flv_path) {
  16. $getid3 = new getID3;
  17. $getid3->encoding = 'UTF-8';
  18. try {
  19. $getid3->Analyze($flv_path);
  20. return $getid3->info['playtime_seconds'];
  21. } catch (Exception $e) {
  22. return 0;
  23. }
  24. }
  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').$_configuration['security_key']));
  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 path like BINARY '/audio/lpi".Database::escape_string($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. {
  63. document.getElementById("audiorecorder_frame").innerHTML = "'.addslashes($recorder_content).'";
  64. document.getElementById("show_audiorecorder_div").style.display="none";
  65. }
  66. </script>
  67. ';
  68. // Commented the audio for the version stable.
  69. //echo '<div id="show_audiorecorder_div"><a style="cursor:pointer" onclick="show_audiorecorder()">'.get_lang('ShowAudioRecorder').'</a></div>';
  70. //echo '<div id="audiorecorder_frame"></div>';
  71. } else {
  72. echo $recorder_content;
  73. }
  74. }