html5-audio

MVC audio controls playing song from bytes

帅比萌擦擦* 提交于 2019-12-05 04:09:30
I have my songs stored in database as bytes[]. How do I use these in the <audio> tag. So something like this. Do I need to convert the bytes to something else first? I am not sure. foreach (var item in Model) { <audio controls> <source src=@item.SongBytes type="audio/mp3"/> </audio> } One way would be to add a new action in your controller that returns the data: public ActionResult Audio(int someId) { byte[] songBytes; // Add code to get data return new FileStreamResult(songBytes, "audio/mp3"); } Then put the URL to that into the src attribute: foreach (var item in Model) { <audio controls>

How can I tell if an HTML5 Audio element is playing with Javascript

泄露秘密 提交于 2019-12-05 03:56:05
I have an audio element in a webpage, and I want to ensure that a user is not still playing it when they leave the page. How can I be sure the audio element is not playing when the page is unloaded? So far, I have the following code, but it doesn't seem to work; the dialog that pops up upon unload reports that playing is false even when the audio is playing: <!DOCTYPE HTML><html> <head> <script><!-- Loading Scripts --> function unloadTasks(){ if (playing && !window.confirm("A podcast is playing, and navigating away from this page will stop that. Are you sure you want to go?")) window.alert(

Web Workers: SetInterval and SetTimeout reliability

你说的曾经没有我的故事 提交于 2019-12-05 03:39:04
In a browser environment, setTimeout and setInterval aren't reliable for accuracy - where time sensitivity is an issue. Recently, we've been given requestAnimationFrame , which allows us to do a little better (in terms of performance.now() and its timestamps). Long story short - I decided to build a metronome in Javascript, and while it works, it's fairly inaccurate above a certain tempo. While compensating for late frames allows the tempo not to desync over time, the individual beats are slightly off, which doesn't work for a metronome. (This is not a problem for animation, as it by nature

Change left/right balance on playing audio in javascript

北慕城南 提交于 2019-12-05 03:00:30
问题 I know the html5 audio stuff is all very new, but is there a way to change the left/right balance on a sound? Something like this: var snd = new Audio("test.mp3"); snd.balance = -1; // only left snd.play(); 回答1: Currently, this is not supported. You can check the w3c spec for supported properties and methods. Note that browsers often provide more / less or different things. But in this case: no browser supports audio balance changes. http://dev.w3.org/html5/spec/Overview.html#audio 来源: https:

Seamless audio loop to an arbitrary position

社会主义新天地 提交于 2019-12-05 01:32:31
One of the things I most love about the MOD format is the ability to loop back to any given point in the song, making it perfect for songs that have an "intro" followed by a "main loop". Of course, MP3 can't do this. Up until now, I've done things like this: <audio src="/path/to/song.mp3" onEnded="this.currentTime = 12.345;"></audio> Where the float value is the time at which the main loop starts. While this works there is a noticeable fraction-of-a-second pause as the audio restarts. I can lessen the effect of this pause by setting the target time a little ahead of where it should be, so the

Preloading HTML5 Audio in Mobile Safari

你。 提交于 2019-12-04 21:51:01
问题 I'm having a problem preloading HTML5 audio content and then using what I have in cache rather than attempting to redownload the audio every time I try to replay it. http://cs.sandbox.millennialmedia.com/~tkirchner/rich/K/kungFuPanda2_tj/ The experience is suppose to be that when someone clicks on the banner, it pops up an ad with a loading bar. THe loading bar is loading all the images necessary for the animation. In the meantime, the audio is also getting loaded via audio tags already on in

Android webview black screen while playing

浪尽此生 提交于 2019-12-04 21:26:42
I'm developing an app that uses WebView to load external video (.mp4), but the page plays only audio, and the video is only "black". I've searched so much and did all possible things to try solve this problem but I failt. Can you help me? MainActivity.java -- REMOVED -- AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="topflix.topflix"> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <application android:allowBackup="true

HTML5 audio player with sub-menus

…衆ロ難τιáo~ 提交于 2019-12-04 20:01:36
I have the following script to play audio files sequence from the selection in menu 1 to the selection in menu 2. It looks like this (a list of Numbers, another for Letters): What I need to do is add two other selection menus, before the action of playing the files, so the selection could be from any menu (even the same one), or other menus (to look like this): So the menu beside the first Select I can choose numbers or letters , and when choosing one them the sub-categories menu beside it changes to show either the selection from 0-5 (if selected numbers ), or from A-C (if the letters is

Play music from bytearray in html5

老子叫甜甜 提交于 2019-12-04 19:50:43
问题 Is there any way to play music from bytes instead of a file in HTML 5? I need to stream music bytes and play them live. 回答1: please check this var dogBarkingBuffer = null; // Fix up prefixing window.AudioContext = window.AudioContext || window.webkitAudioContext; var context = new AudioContext(); function loadDogSound(url) { var request = new XMLHttpRequest(); request.open('GET', url, true); request.responseType = 'arraybuffer'; // Decode asynchronously request.onload = function() { context

HTML5 Audio Element \" src = get.php cannot skip position

醉酒当歌 提交于 2019-12-04 18:27:40
I am using the HTML5 AudioElement to play my .mp3 files, but I noticed it is not possible to skip the position. I am fetching the file via PHP from outside the www root. I am using HTML code : <audio src="" controls id="appAudio" style="width:1000px;margin-top:10px"></audio> JavaScript code: document.getElementById('appAudio').src= 'http://localhost/index.php/player/get_audio_via_php/1'; PHP code: $file = "/myfolder/1.mp3"; header('Content-Type: audio/mpeg'); header('Content-Length: ' . filesize($file)); return file_get_contents($file); Like I said it does play the audio file, but skipping