Play audio local file with html

You set the src attr directly on the audio element. fiddle var $audio = $(‘#myAudio’); $(‘input’).on(‘change’, function(e) { var target = e.currentTarget; var file = target.files[0]; var reader = new FileReader(); console.log($audio[0]); if (target.files && file) { var reader = new FileReader(); reader.onload = function (e) { $audio.attr(‘src’, e.target.result); $audio.play(); } reader.readAsDataURL(file); } }); <script … Read more

How do you check if music is playing by using a broadcast receiver?

You don’t need a broadcast receiver for this – AudioManager is your friend: AudioManager.isMusicActive() does the job you want, have a closer look here for details: AudioManager here is an example: AudioManager manager = (AudioManager)this.getSystemService(Context.AUDIO_SERVICE); if(manager.isMusicActive()) { // do something – or do it not }

Android: How to create fade-in/fade-out sound effects for any music file that my app plays?

This is my entire handler class for Android MediaPlayer. Look at the play() and pause() functions. Both contain the ability to either fade or not. The updateVolume() function was the key to let the sound increase/decrease linearly. package com.stackoverflow.utilities; import java.io.File; import java.util.Timer; import java.util.TimerTask; import android.content.Context; import android.media.MediaPlayer; import android.net.Uri; public class MusicHandler { … Read more

How to download audio/video files from internet and store in iPhone app?

Creating a Folder For every app you have a Documents Folder. Any files you use in your app are stored here. If you want to create more directories here, then you’d do something like this: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@”MyNewFolder”]; … Read more

READ_EXTERNAL_STORAGE permission for Android

You have two solutions for your problem. The quick one is to lower targetApi to 22 (build.gradle file). Second is to use new and wonderful ask-for-permission model: if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (shouldShowRequestPermissionRationale( Manifest.permission.READ_EXTERNAL_STORAGE)) { // Explain to the user why we need to read the contacts } … Read more