I want to play mp3 file in my website using html.
Basically the mp3 file will be from remote server. As soon as user click play button, I dont want to download(stream) whole mp3 file and then play.
Instead of that I want to stream small chunks to be downloaded from server using nodejs and sent them to browser, browser will play that part.
meanwhile node js will continue stream the other parts.
so basiacally I am looking for youtube kind of implementation for audio where song will play for whatever part is streamed or downloaded
So anyone can explain me how can I achieve this in node js ? do I have to use socket.io ?
Related
I have a program that plays songs from the server. To make it more efficient i split the audio file on server into segments and the send them to the client using Ajax as base64 encoded. The HTML5 native audio player plays the base64 audio segment but when playing the next audio segment, it pauses a little and then plays. The retrieved segments are stored in IndexedDB for quick access but still it causes a pause in the playback. How to make the program more efficient as well as fix the audio pause happening between switching segments.
Is there any other way of appending audio file to a currently playing audio source without any pause using Javascript?
The Media Source Extensions API can do that, but note that you are just reinventing Range requests and caching, which are exactly what browsers already do for fetching media, but they do it better since they don't add the overhead of base64 on it.
So the "other way" is to configure your server to accept Range requests, to serve your file the most basically as possible in a single file, and to let the browser do its job.
I am creating an app to trim video where a user either can upload the video file or can paste YouTube URL.
I am able to make the trimmer work for upload video using FFmpeg, but for YouTube URL, firstly I need to download the video to the local machine and then trim it using FFmpeg.
I am using youtube-dl NodeJS library to save the video file to locally, but the issue is as I am allowing the user to download only 15Sec video no more than that, and I have applied validation of 60m long video, yet when I get 1080p video there are two issues.
1. There is no audio in the 1080p video.
and
2. The video is taking too long to download locally and the process is taking almost 7-8mins to complete.
For the first one, I can get the audio and video separately and then merge both of them in the video, but the second one is where I am stacked.
I have added a time log I can see the trimming is taking only about 3-4 seconds, but the downloading is taking too long.
Is there any way to make it work faster? Or, Is there any way I can download only that part of the video, not the full video, in any technology.
I am open to using any technology until it is working faster than my current implementation.
If this is something related to server configuration, please suggest which one would work better.
I have an asp.net web application that allows a user to record audio. I'm using code from https://github.com/nusofthq/Recordmp3js along with Matt Diamond's recorder files (modified for wav instead of mp3). Not sure if it matters but I'm using the updated API for mediaDevices.getUserMedia().
The recording works fine, the wav file is saved to disk, and if I listen to the file on disk I can hear the recording. However, if I try to play the audio back through the HTML5 audio control on the page, there is no sound. The length of the file matches what is on disk so I don't think it's because the audio control is unable to find the file.
I can post my Javascript if that will be helpful. I'm currently testing on localhost using Firefox. Firebug doesn't show any errors.
Please let me know if any additional information may be helpful.
Thank you!
The (quickest) solution was to reset Firefox. Wav files now play without any issues.
I'm reading a book about Web Audio API.
In the book it states that to play and load a sound using the WEB AUDIO API, there are 4 steps that needs to be taken:
1.) Load the sound file with XHR and decode it. (Will end up with a 'buffer')
2.) Connect the buffer to audio effects nodes.
3.) To hear the sound, connect the last node in the effects chain to the destination.
4.) Start the sound.
My question is...given these 4 steps, is there a way for the user of the website that uses the Web Audio to download the audio/audios played on the website???
If so, how does one prevent this.
or does it being 'buffered' prevent it from being illegally downloaded?
I would like to find a way to protect the audio files I use inside my game/app that I put up on the webpage that are played with the Web Audio API.....
Thank you....
EASILY save it, no. But 1) if it's being transferred as an MP3, etc file the user can go into their network cache and copy it; there's no inherent DRM or anything. 2) Even if the sound was being generated completely from scratch (e.g. mathematically) the user could use a virtual audio device like Soundflower to save the output.
So no, it's not really possible to prevent the user from saving audio files.
I am trying to stream an mp3 via javascript/html5 or flash on my webserver.
The javascript/html front end calls a script on the server which begins generating an mp3 file.
I want the file to begin playback immediately once enough audio is buffered, and to continue playing.
I am new to streaming and want to know the best method to do this in both apache server and windows iis.
At first I thought I would need to use an actual streaming protocol, such as rtp or rtsp, but it seems like it maybe better using a custom javascript player that takes the mp3 file in via http.
However the concern with http is that the file transfer will stop once the incomplete tail of the mp3 file is hit. Is there a way around this, perhaps altering the config to make the apache/iis server wait until the file is complete before terminating the transfer?
I also looked into m3u files but this seems to require a complete mp3 file, although I'm not clear on it.
Any advice/solutions/examples will be appreciated.
I don't have the exact solution, but you can try this http://learningsfromdotnet.blogspot.com/2011/11/playing-mp3-using-audio-tag-html-5-in.html.
I was trying to stream MP3 file from IIS server, had issue with Chrome because it makes a request with "Range" header. If you can make similar request with "Range" header and from server stream the piece of MP3, it might work.