2012-02-20 2 views
9

저는 Wami Recorder에 매우 익숙합니다. Flash로 전혀 작업 한 적이 없기 때문에 실제로는 바보 같은 질문 일 수 있습니다.Wami 레코더는 실제로 어떻게 구현 되었습니까?

기본적으로 Wami 레코더를 구현하는 방법은 무엇입니까? 나는 웹 사이트에서 그것을 보았고, 거기에서 훌륭하게 작동하지만, Xampp의 일부로 localhost 내에서 그것을 사용하려고 시도 할 때, 작동하지 않는다.

누군가가 Wami Recorder for Dummies 답을 작성할 수 있다면 정말 멋질 것입니다.

누군가 CakePHP 2.0에서 특히 프레임 워크 내에서 그것을 사용하는 방법을 알고 있다면 이것을 사용하고 있습니다.

기본적으로 오디오를 녹음하고 디렉토리에 파일을 저장하고 파일에 대한 특정 세부 정보를 데이터베이스에 저장할 수있는 POST 정보가 있습니다.

답변

15

그래, 문서가 명확하지 않습니다. 나는 어제 오후 내내 그것을 알아 냈다. 다음은 로컬 시스템에서 작동하는 간단한 구현입니다. 다음 파일은 Apache 웹 페이지의 "/ temp/wami/test"에 저장되므로 URL은 http : // localhost/temp/wami/test/"

index.html
레코더입니다. JS
save_file.php
Wami.swf

index.html을

<!-- index.html --> 
    <html> 
    <head> 
     <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> 
     <script src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script></script> 
     <script src="recorder.js"></script> 
    </head> 

    <body> 
     <div id="recorder"> 
      <button id="record">Record</button> 
      <button id="play">Play</button> 
     </div> 
     <div id="flash"></div> 
    </body> 

    <script> 
     // initialize Wami 
     Wami.setup({ 
      id: 'flash' // where to put the flash object 
     }); 

     // initialize some global vars 
     var recording = ''; 
     var recordingUrl = ''; 
     var playBackUrl = ''; 

     // get button elements 
     var record = $('#record'); 
     var play = $('#play'); 

     // define functions 
     function startRecording() { 
      recording = 'temp.wav'; 
      recordingUrl = 'http://localhost/temp/wami/test/save_file.php?filename=' + recording; 
      Wami.startRecording(recordingUrl); 
      // update button attributes 
      record 
       .html('Stop') 
       .unbind() 
       .click(function() { 
        stopRecording(); 
       }); 
     } 

     function stopRecording() { 
      Wami.stopRecording(); 
      // get the recording for playback 
      playBackUrl = 'http://localhost/temp/wami/test/' + recording; 
      // update button attributes 
      record 
       .html('Record') 
       .unbind() 
       .click(function() { 
        startRecording(); 
       }); 
     } 

     function startPlaying() { 
      Wami.startPlaying(playBackUrl); 
      // update button attributes 
      play 
       .html('Stop') 
       .unbind() 
       .click(function() { 
        stopPlaying(); 
       }); 
     } 

     function stopPlaying() { 
      Wami.stopPlaying(); 
      // update button attributes 
      play 
       .html('Play') 
       .unbind() 
       .click(function() { 
        startPlaying(); 
       }); 
     } 

     // add initial click functions 
     record.click(function() { 
      startRecording(); 
     }); 

     play.click(function() { 
      startPlaying(); 
     }); 
    </script> 

    </html> 

save_file.php

<?php 
    /* save_file.php */ 

    // get the filename 
    parse_str($_SERVER['QUERY_STRING'], $params); 
    $file = isset($params['filename']) ? $params['filename'] : 'temp.wav'; 
    // save the recorded audio to that file 
    $content = file_get_contents('php://input'); 
    $fh = fopen($file, 'w') or die("can't open file"); 
    fwrite($fh, $content); 
    fclose($fh); 

그렇게해야합니다. 불행히도 녹음을 일시 중지했다가 다시 시작할 수있는 방법이없는 것 같습니다. 녹음을 시작할 때마다 이전 오디오를 덮어 씁니다. 또한 오디오 파일에 대한 정보 (예 : 길이, 크기)를 검색하는 방법으로 보이지 않습니다. 레코더 기능의 전체 목록은 Wami 레코더 파일 (recorder.js)을 참조하십시오.

+0

정말 고마워요 !!!! –

+0

그러나 나는 녹음 기능을 얻지 못했지만 대답을 던졌습니다. – ronan

+0

감사합니다. 매력처럼 작동했습니다! 쓰기 가능한 파일을 저장할 디렉토리를 만드는지 확인하십시오 :-) –

관련 문제