php - jrecorder插件问题
PHPz
PHPz 2017-04-10 14:22:20
[PHP讨论组]

问题是这样的:前几天我在网上下了一个插件jrecorder,这是一个不需要任何flash编程技术就可以实现在线录音的jquery插件,但问题出现了,我在http://www.sajithmr.me/jrecorder/exam... 上下了插件,也按照提示把插件装在本地服务器上,但是老是出错:Uncaught TypeError: Object #<HTMLObjectElement> has no method 'jStartRecording' ;jStartRecording函数在jrecorder.js中:

//function call to start a recording
	$.jRecorder.record = function(max_time){
		//change z-index to make it top
	$(  '#' + jRecorderSettings['recorderlayout_id'] ).css('z-index', 1000);
    getFlashMovie(jRecorderSettings['recorder_name']).jStartRecording(max_time);
} 

本地测试时使用的代码:

<html>
<head>
<meta name="author" content="Sajith Amma" />
<script src="../js/jquery.min.js"> </script>
<script src="../js/jRecorder-1.0-old.js"> </script>
<title>jRecorder Example</title>  
</head>
<body> 
<p id="locationforrecorder" style="border:1px solid grey">
</p>  
<script>
$.jRecorder(
     
    { 
     host : 'http://localhost/nahan/recorder/acceptfile.php?filename=hello.wav' ,        
     callback_started_recording:     function(){callback_started(); },
     callback_stopped_recording:     function(){callback_stopped(); },
     callback_activityLevel:  function(level){callback_activityLevel(level); },
     callback_activityTime:     function(time){callback_activityTime(time); },
     callback_finished_sending:     function(time){ callback_finished_sending() },
     swf_path : 'jRecorder.swf',
    }
    , $('#locationforrecorder')
    );
</script>
  <p style="background-color: #eeeeee;border:1px solid #cccccc">  
    Time: <span id="time">00:00</span>  
  </p>
  <p>
    Level: <span id="level"></span>
  </p>  
  <p id="levelbase" style="width:200px;height:20px;background-color:#ffff00">
     <p id="levelbar" style="height:19px; width:2px;background-color:red"></p>  
  </p>
  <p>
    Status: <span id="status"></status>
  </p> 
  <p>  
    <input type="button" id="record" value="Record" style="color:red">  
    <input type="button" id="stop" value="Stop">
  </p>
  <script type="text/javascript">                
    $('#record').click(function(){
      $.jRecorder.record(30);                    
   })                  
    $('#stop').click(function(){                                     
      $.jRecorder.stop();                                     
   })                  
   function callback_finished()
    {     
       $('#status').html('Recording is finished');                   
    }                  
   function callback_started()
    {      
       $('#status').html('Recording is started');
    }  
    function callback_error(code)
      {
         $('#status').html('Error, code:' + code);
      }
   function callback_stopped()
    {
      $('#status').html('Stop request is accepted');
    }
   function callback_finished_recording()
    {                    
      $('#status').html('Recording event is finished');                                       
    }
   function callback_finished_sending()
    {                    
     $('#status').html('File has been sent to server mentioned as host parameter');
    }
   function callback_activityLevel(level)
    {                    
     $('#level').html(level);                    
        if(level == -1)
         {
            $('#levelbar').css("width",  "2px");
         }
         else
         {
            $('#levelbar').css("width", (level * 2)+ "px");
         }                                        
    }
    function callback_activityTime(time)
     {                   
       //$('.flrecorder').css("width", "1px"); 
       //$('.flrecorder').css("height", "1px"); 
       $('#time').html(time);                    
     }
    
 </script>
</body>
</html>

我查看了网上那个示例的源代码,发现和我本地上的代码没有区别,所以真的很郁闷,到底哪里出错了?

PHPz
PHPz

学习是最好的投资!

全部回复(2)
巴扎黑

把所有JS代码放到$(function() { ~~~~~~~~放置jRecorder代码~~~~~~~~~~~ })

PHP中文网

解决了没有?

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号