2012-02-20 18 views
9

मैं वामी रिकॉर्डर के लिए बहुत नया हूं, और मैंने फ्लैश के साथ कभी भी काम नहीं किया है, इसलिए यह वास्तव में एक बेवकूफ सवाल हो सकता है।वामी रिकॉर्डर वास्तव में कैसे कार्यान्वित किया जाता है?

असल में, वामी रिकॉर्डर को लागू करने के बारे में कोई कैसे जाता है? मैंने इसे वेबसाइट पर देखा है, और यह वहां पर बहुत अच्छा काम करता है, लेकिन जब मैं इसे डाउनलोड करता हूं और Xampp के हिस्से के रूप में इसे स्थानीयहोस्ट के भीतर उपयोग करने का प्रयास करता हूं, तो यह काम नहीं करता है।

अगर कोई डमीज़ उत्तर के लिए वामी रिकॉर्डर लिख सकता है, तो वह पूरी तरह से कमाल होगा।

मैं इसका उपयोग केकपीएचपी 2.0 में कर रहा हूं यदि कोई जानता है कि विशेष रूप से उस ढांचे के भीतर इसका उपयोग कैसे किया जाए।

असल में मैं जो करने की कोशिश कर रहा हूं वह रिकॉर्ड ऑडियो है, फ़ाइल को निर्देशिका में सहेजता है, और POST जानकारी फ़ाइल के बारे में कुछ विवरण डेटाबेस में सहेजने में सक्षम होने के लिए है।

उत्तर

15

हाँ, दस्तावेज़ीकरण बहुत स्पष्ट नहीं है। मैंने कल दोपहर बिताए और इसे समझ लिया। यहां एक सरल कार्यान्वयन है जो मेरी स्थानीय मशीन पर काम करता है। निम्न फ़ाइलों में "/ अस्थायी/वामी/परीक्षण" मेरे अपाचे दस्तावेज़ जड़ के नीचे जमा हो जाती है, तो यूआरएल है "http: // localhost/अस्थायी/वामी/परीक्षण /":

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); 

ऐसा करना चाहिए। दुर्भाग्यवश, रोकना और फिर रिकॉर्डिंग फिर से शुरू करने का एक तरीका प्रतीत नहीं होता है। प्रत्येक बार जब आप रिकॉर्डिंग शुरू करते हैं तो यह पिछले ऑडियो को ओवरराइट करता है। ऑडियो फ़ाइल (उदा। लंबाई, आकार) के बारे में जानकारी पुनर्प्राप्त करने का एक तरीका भी प्रतीत नहीं होता है। रिकॉर्डर कार्यों की पूरी सूची के लिए वामी रिकॉर्डर फ़ाइल (recorder.js) देखें।

+0

बहुत बहुत धन्यवाद !!!! –

+0

मैं जवाब फेंक रहा था हालांकि मुझे रिकॉर्डिंग समारोह नहीं मिला – ronan

+0

धन्यवाद, एक आकर्षण की तरह काम किया! सुनिश्चित करें कि आप निर्देशिका बनाते हैं जहां आप फ़ाइल लिखने योग्य फ़ाइल को सहेजना चाहते हैं :-) –