audio-player

Android SeekBar setProgress is causing my MediaPlayer to skip

风流意气都作罢 提交于 2019-11-29 03:04:42
问题 I'm trying to use a SeekBar to display both the length of a track played by a MediaPlayer class and to enable seeking within the track. Seeking within the track works well. However, updating the progress value using setProgress while the track is playing seems to cause a slight skip. In the onCreate method I create a Thread with a loop which updates the SeekBar's progress value for the current track. This loop resets when the track is changed. private void createProgressThread() {

How to play Audio file Mp3 from the server [duplicate]

╄→尐↘猪︶ㄣ 提交于 2019-11-29 02:25:22
问题 This question already has an answer here: How can I play a mp3 without download from the url? [closed] 6 answers I want to play audio from the live server. I don't want to download these audio files. Format of these files are mp3.working on android java. 回答1: try { MediaPlayer player = new MediaPlayer(); player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.setDataSource("http://xty/MRESC/images/test/xy.mp3"); player.prepare(); player.start(); } catch (Exception e) { // TODO: handle

Is there a way to access the currently played track while the iPhone is connected to an accessory?

丶灬走出姿态 提交于 2019-11-29 02:02:54
问题 I am trying to receive information about the currently played track in a iOS app. This works pretty fine while the iPhone is not connected to an accessory. If I connect it to my car (Opel Astra, iPhone jack), the following code stops to work as described in the documentation: If you create an iPod music player and the user plays an item from another library using Home Sharing, the value of this property is nil . Code: // nil while connected to an accessory MPMediaItem *nowPlayingMediaItem = [

How To Add Media To MediaStore on Android 4.4 KitKat SD Card With Metadata

六眼飞鱼酱① 提交于 2019-11-28 22:01:51
Background: In Android 4.4, Google decided that apps should not have write access to SD cards . However, apps can write to /SDCard/Android/data/App Package Name. So this is what I've done. I have written an MP3 file to /Android/data/. I then want this MP3 file to show up in Android music players. I've tried the following... sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + filePath))); and.... MediaScannerConnection.scanFile(this, new String[] { file.toString() }, new String[] {"audio/*"}, new MediaScannerConnection.OnScanCompletedListener() { public void

Audio Player play in background and should work based off of hardware mute switch

北战南征 提交于 2019-11-28 21:54:24
I want to play audio file in the foreground, background and it should work with mute switch i.e. if mute switch is on, then it should not play, if mute switch is off should play audio. **I'm developing an SIP call application. App should play sound/ringtone when user receives a call. It should play if app is in background/foreground, it should mute/unmute if hardware mute switch is ON/OFF. For this I used AVPlyaer with below code. AVAudioSession *session = [AVAudioSession sharedInstance]; [session setCategory:AVAudioSessionCategoryPlayback error:&error]; [session setActive:YES error:nil];

Detecting if music is playing?

我只是一个虾纸丫 提交于 2019-11-28 21:52:55
My app involves music(iPodMusic), and there is a UISwitch toggling play/pause. My goal is to be able to detect if music is playing, so that therefore the play/pause switch can say 'play' when music is playing and 'pause' if it isn't. if ([[MPMusicPlayerController iPodMusicPlayer] playbackState] == MPMusicPlaybackStatePlaying) ... If the music is from your own app, check AVAudioPlayer's playing property . If the music is from iPod, check MPMusicPlayerController's nowPlayingItem or playbackState property. MPMusicPlayerController is only available in OS 3.0 or above. If you're running 2.0 you're

How to play local mp3 file with audioplayer plugin in Flutter

元气小坏坏 提交于 2019-11-28 20:55:47
How to play local mp3 file with audioplayer 0.2.0 in Flutter. pubspec.yaml flutter: assets: - sounds/music.mp3 main.dart Future<ByteData> loadAsset() async { return await rootBundle.load('sounds/music.mp3'); } // FIXME: This code is not working. Future playLocal() async { final result = await audioPlayer.play(loadAsset()); if (result == 1) setState(() => playerState = PlayerState.playing); } Can I get local assets path from rootBundle? Can I pay audio from ByteData on audioPlayer? The audioplayer plugin currently only supports network paths and files. You can move an asset to a temporary

Android - MediaPlayer Buffer Size in ICS 4.0

早过忘川 提交于 2019-11-28 16:12:08
I'm using a socket as a proxy to the MediaPlayer so I can download and decrypt mp3 audio before writing it to the socket. This is similar to the example shown in the NPR news app however I'm using this for all Android version 2.1 - 4 atm. NPR StreamProxy code - http://code.google.com/p/npr-android-app/source/browse/Npr/src/org/npr/android/news/StreamProxy.java My issue is that playback is fast for 2.1 - 2.3, but in Android 4.0 ICS the MediaPlayer buffers too much data before firing the onPrepared listener. An example amount of data written to the Socket OutputStream before onPrepared(): On

Uninterrupted background music on website

给你一囗甜甜゛ 提交于 2019-11-28 12:21:46
I was making a website for a music band, and i was wondering the best way to play background music on the website without interrupting the flow of the music (even for a split second). At the moment, i am considering using frames, but this is not supposed to be good practice. Please someone tell me how i can do this. I would prefer to use HTML to code the website as i have not yet mastered coding in flash. Alex Fort This might sound controversial, but here's an idea: Don't play music on your website. Seriously, don't. I think everyone knows how incredibly annoying that is, and asking a group of

AVAudioPlayer currentTime issue

孤人 提交于 2019-11-28 11:37:03
问题 I'm trying to use the AVAudioPlayer with a slider in order to seek into a track (nothing complicated). But I have a weird behavior... for some value of currentTime (between 0 and trackDuration), the player stop playing the track, and goes into audioPlayerDidFinishPlaying:successfully: with successfully to NO. And it did not go into audioPlayerDecodeErrorDidOccur:error: It's like it can't read the time I'm giving to it. For exemple the duration of the track is: 295.784424 seconds I set the