Browser Audio js execute question

0 favourites
  • 5 posts
From the Asset Store
This is a single chapter from the Construct Starter Kit Collection and the Student Workbook from the Workshop.
  • im currently playing audio files with browser

    by using the bellow execution

    "var aud = new Audio();

    aud.src = '"&FileChooser.FileURLAt(0)&"';

    aud.play();

    "

    everytime i import a new song it plays over the old one and sound duplicates

    i tried using this "sound.pause();

    sound.currentTime = 0;

    " before i play a new audio but if i do that the global volume stops and the audio files aren't heard anymore

    is there a way when i load a new song to stop the old song? i know i have to add a tag or name to the object but my skills are really poor on js.

  • Why not just use the Audio plugin?

  • Why not just use the Audio plugin?

    the project im working on(to kill my time and make something cool using C2 and Q3D) requires mp3/ogg/wave audio formats to be played... but users after i finish the project wont sit to convert to .ogg or any other format.. they will want to import a mp3 file directly since its the most common format on internet ...

    i have a combination of filechooser and browser js snippet to play any audio format and read a song pcm data

    which gives me a full preloaded waveform of any audio format...

    but i cant add the audio analyser effect to it since the audio plugin is not playing that song but a new audio object that i made in the browser...

    so now i need to get a js execution and basically reinvent everything to work around the audio plugin inability of playing mp3's and read the full waveform before playing the audio file in this case the music files that users wold choose to import.

    all this wold be avoided if audio plugin could play mp3's alone with the other formats

    the audio plugin works perfect for the rest of the project... but mp3s and pcm data is the main game (ex of gameplay :

    Subscribe to Construct videos now

    )

    with the help of R0j0Hound i have the bellow capx...

    which i adapted to work with the Q3d and i have a pretty close simulation as audiosurf... just now im missing the analyser effect which wold give me the beats reading while playing and ability to use those as speed boosting and notes/blocks spawning.

    its a pretty easy project ... but gives me headaches since im a bit more clumsy then normal people with js.

    capx: import any audio format and create a linear waveform - doesn't require custom plugins.

    now since i explained what im doing...

    the main audio js execution i need.. is for me to stop the audio playing... if i import a new song in the above capx .... for that i know i need a tag or name for each audio object i create... or i could destroy the audio object of the previews song and then create a new one when a new file is imported. ... or i can change the source... but for that i need to stop creating a new audio ... and that i have no clue how to do..

    but as i said above... my js skills are similar to a preschool kid assembling puzzles.

    as for the audio analyser its not a problem... i can calculate the length of each waveform line and convert it to a fictional speed when player is in proximity creating the illusion of speed boosting on beat.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can probably find the blog post by ashley about the audio formats supported by C2 and why. It's mainly due to the need to be able to convert the audio to multiple formats so the audio is playable everywhere. Mp3 has licencing stuff associated with it's file format when reading/writing it so that's why it might not be suggested. Different browsers support playback of different formats as listed here:

    https://developer.mozilla.org/en-US/doc ... ia_formats

    In actuality all I think you're looking for is the ability to play a sound from an url with the audio plugin. So a feature request perhaps?

  • R0J0hound

    yea the formats post i read it and remember the reasons about the mp3 licensing which i agree they are pretty high and i understand the inconvenience ... but a link playing request i guess wold solve it

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)