Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6684233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:54:59+00:00 2026-05-26T04:54:59+00:00

Is it possible to first upload an mp3 file with the html5 drag and

  • 0

Is it possible to first upload an mp3 file with the html5 drag and drop upload system, and then play it with webkit’s audio API (http://chromium.googlecode.com/svn/trunk/samples/audio/index.html) without submitting a form (in Google Chrome)? Is it possible to do in FF with Mozilla’s audio API? If so, how? Also, are there any tutorials in existance for webkit’s API? I have not been able to find any.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:54:59+00:00Added an answer on May 26, 2026 at 4:54 am

    The basic process you need to follow is

    1. Capture the files using Drag and Drop Files
    2. Posting the files in a Form Data Object
    3. Respond with the URL of the audio item you want to play
    4. Play the Audio using the Audio API

    This jsFiddle allows you to drag an audio file into an area and it will then play that file.

    You should be able to use the JavaScriptAudioNode‘s onaudioprocess event to get the current amplitude.

    Edit:

    Based on what JaapH said I had a look into this again. The processor was used to get an appropriate event to render the canvas. So it is not really required. This jsFiddle does the same as below. However, it uses requestAnimationFrame instead of the processor.

    Here is the old code, see the fiddle above for the version using request animation frame:

    var context = new (window.AudioContext || window.webkitAudioContext)();
    var source;
    var processor;
    var analyser;
    var xhr;
    
    function initAudio(data) {
        source = context.createBufferSource();
    
        if(context.decodeAudioData) {
            context.decodeAudioData(data, function(buffer) {
                source.buffer = buffer;
                createAudio();
            }, function(e) {
                console.log(e);
            });
        } else {
            source.buffer = context.createBuffer(data, false /*mixToMono*/);
            createAudio();
        }
    }
    
    function createAudio() {
        processor = context.createJavaScriptNode(2048 /*bufferSize*/, 1 /*num inputs*/, 1 /*numoutputs*/);
        processor.onaudioprocess = processAudio;
        analyser = context.createAnalyser();
    
        source.connect(context.destination);
        source.connect(analyser);
    
        analyser.connect(processor);
        processor.connect(context.destination);
    
        source.noteOn(0);
        setTimeout(disconnect, source.buffer.duration * 1000);
    }
    
    function disconnect() {
        source.noteOff(0);
        source.disconnect(0);
        processor.disconnect(0);
        analyser.disconnect(0);
    }
    
    function processAudio(e) {
        var freqByteData = new Uint8Array(analyser.frequencyBinCount);
        analyser.getByteFrequencyData(freqByteData);
        console.log(freqByteData);
    }
    
    function handleResult() {
        if (xhr.readyState == 4 /* complete */) {
            switch(xhr.status) {
                case 200: /* Success */
                    initAudio(request.response);
                    break;
                default:
                    break;
            }
            xhr = null;
        }      
    }
    
    function dropEvent(evt) {
        evt.stopPropagation();
        evt.preventDefault();
    
        var droppedFiles = evt.dataTransfer.files;
    
        //Ajax the file to the server and respond with the data
    
        var formData = new FormData();
        for(var i = 0; i < droppedFiles.length; ++i) {
                var file = droppedFiles[i];
    
                files.append(file.name, file);
        }
    
        xhr = new XMLHttpRequest();
        xhr.open("POST", 'URL');  
        xhr.onreadystatechange = handleResult;
        xhr.send(formData);
    }
    
    function dragOver(evt) {
        evt.stopPropagation();
        evt.preventDefault();
        return false;
    }
    
    var dropArea = document.getElementById('dropArea');
    dropArea.addEventListener('drop', dropEvent, false);
    dropArea.addEventListener('dragover', dragOver, false);
    

    I hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to upload a file through html to javascript without having to
I am trying to upload a file from browser, then make one thumbnail from
I'm wondering if it is possible, to upload a file from the local Computer
If I upload a text file via a form, is it possible to output
first of all my question: Is it possible to pass file names from a
Is it possible to update first row and with WHERE clause. I Tried: UPDATE
Possible Duplicate: iPhone development on Windows We are about to begin our first med-tech
First of all I'm not sure this is even possible, however I need to
Is it possible to uppercase the first character of each word using regex? I'm
Is it possible to display all but first row from a table in sql

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.