audio-player

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

人走茶凉 提交于 2019-11-26 12:43:05
问题 I would like to prevent some of my code from executing only when music or videos are currently playing. How would I accomplish this using a broadcast receiver? 回答1: 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

READ_EXTERNAL_STORAGE permission for Android

假如想象 提交于 2019-11-26 12:15:13
I'm trying to access media files (music) on the users device to play them; an easy "hello world"-music player app. I've followed some tutorials and they basically give the same code. But it won't work; it keeps crashing and telling me: error..... Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/audio/media from pid=27696, uid=10059 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission() .... Now, this is my manifest file: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=

Play audio local file with html

笑着哭i 提交于 2019-11-26 11:30:54
问题 I\'m trying to do something like this. But I don\'t know why I\'m not getting this thing work. Here it is the codepen example: $(\'input\').on(\'change\', function(e) { var file = e.currentTarget.files[0]; var reader = new FileReader(); reader.onload = function(e) { $(\'audio source\').attr(\'src\', e.target.result); } reader.readAsDataURL(file); }); The source tag is receiving the base64 mp3 file, but it doesn\'t load the file into browser. 回答1: You set the src attr directly on the audio

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

醉酒当歌 提交于 2019-11-26 10:58:40
问题 The application that I am working on plays music files. If a timer expires I want the music to fade out. How do I do that. I am using MediaPlayer to play music and music files are present in raw folder of my application. 回答1: One way to do it is to use MediaPlayer.setVolume(right, left) and have these values decrement after every iteration..here is a rough idea float volume = 1; float speed = 0.05f; public void FadeOut(float deltaTime) { MediaPlayer.setVolume(volume, volume); volume -= speed*

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

二次信任 提交于 2019-11-26 10:18:15
问题 I am developing an iPhone app for music. I want to give some options to the user so they can listen the song/music by streaming or they can download the music in the app . I know how to stream the audio files in the app programmatically. But, i don\'t know how to download the audio files in the app and play the audio after download. And also user can pause the download while it is in download. Is it possible to do ? Can anyone please guide me and please share any sample code or tutorial for

Android - Playing mp3 from byte[]

倖福魔咒の 提交于 2019-11-26 04:09:30
问题 I have my mp3 file in byte[] (downloaded from an service) and I would like to play it on my device similar to how you can play files: MediaPlayer mp = new MediaPlayer(); mp.setDataSource(PATH_TO_FILE); mp.prepare(); mp.start(); But I can\'t seem to find a way to do it. I wouldn\'t mind saving file to phone and then playing it. How can I play the file, or download then play it? 回答1: OK, thanks to all of you but I needed to play mp3 from byte[] as I get that from .NET webservice (don't wish to

READ_EXTERNAL_STORAGE permission for Android

假如想象 提交于 2019-11-26 02:52:53
问题 I\'m trying to access media files (music) on the users device to play them; an easy \"hello world\"-music player app. I\'ve followed some tutorials and they basically give the same code. But it won\'t work; it keeps crashing and telling me: error..... Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/audio/media from pid=27696, uid=10059 requires android.permission.READ_EXTERNAL_STORAGE, or