media-player

How do Android mediaplayers continuing playing songs when app is closed?

大兔子大兔子 提交于 2019-11-27 01:59:51
问题 Wondering how next songs are played once app is closed as if playing an entire CD or playlist... 回答1: The media player only plays one audio track. What media players do, is listen on the onCompletion event and play the next track. The MediaPlayer is bound to the process, not the activity, so it keeps playing as long as the process runs. The activity might be paused or destroyed, but that won't affect the internal thread that MediaPlayer uses. I'm building an audio player to learn Android, you

Accuracy of MediaPlayer.seekTo(int msecs)

时间秒杀一切 提交于 2019-11-27 01:48:26
问题 Why is MediaPlayer.seekTo(int msec) so inaccurate? It's sometimes 30 seconds early (with mp3's of both variable and constant bitrates)! Is seeking with audio inherently problematic or is this method broken? Is it to do with buffering or what? I've also noticed that the total runtime getDuration() can be wrong (which isn't a big issue) and I've tested that getCurrentPosition() is accurate enough (as in every n seconds of playback, it increases by n thousand). I'm on Android 2.2. Finally, does

Play audio through upper (phone call) speaker

。_饼干妹妹 提交于 2019-11-27 01:41:23
问题 I'm trying to get audio in my app to play through the upper speaker on the iPhone, the one you press to your ear during a phone call. I know it's possible, because I've played a game from the App Store ("The Heist" by "tap tap tap") that simulates phone calls and does exactly that. I've done a lot of research online, but I'm having a surprisingly hard time finding ANYONE who has even discussed the possibility. The overwhelming majority of posts seem to be about the handsfree speaker vs

Android : How to set MediaPlayer volume programmatically?

懵懂的女人 提交于 2019-11-27 00:51:47
问题 How to set the mediaplayer volume programmatically. I use it for alarm notification. Any help is highly appreciated and thanks in advance. 回答1: Using AudioManager you can control the volume of media player. AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE); audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 20, 0); also from MediaPlayer (But I didn't try that) public void setVolume (float leftVolume, float rightVolume) Since: API Level 1 Sets the volume on

Online radio streaming app for Android

和自甴很熟 提交于 2019-11-26 23:29:50
I'm building an Android app that will stream several radio stations from a Latin Country, there is like 10 stations that I know can be played in android, I got the URL's from them and actually made them work using this tutorial (link removed, because it is dead) but the problem I have is that it plays for several seconds and then stops it keeps loading but does not restart the streaming, my questions: If someone has worked with this tutorial can explain me how to make it stream constantly with out stopping. Is there an easier way to stream radio audio? this tutorial seems kind of old, is there

Receive OS level key-press events in C# application

强颜欢笑 提交于 2019-11-26 23:15:42
问题 i dont know a better title for the question , but i`ll illustrate my problem. I am working on application that acts like a mp3 player , it uses the Multimedia keys to play/pause , stop the song , i actually made it work but the FormApplication must be in the top [Focused] protected override void WndProc(ref Message msg) { if (msg.Msg == 0x319) // WM_APPCOMMAND message { // extract cmd from LPARAM (as GET_APPCOMMAND_LPARAM macro does) int cmd = (int)((uint)msg.LParam >> 16 & ~0xf000); switch

Sorry, this video is not valid for streaming to this device in Http streaming android

风格不统一 提交于 2019-11-26 23:11:44
问题 I can stream some videos from URL (server) successfully, But the others (my video up to my server) is not . You can see both in my code (Working/Not working) I'm on stuck with this problem. "Sorry, this video is not valid for streaming to this device" The following code : String url = null; // url = "rtsp://v5.cache5.c.youtube.com/CiILENy73wIaGQmC00ZlwwIDOxMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"; // Working // url = "http://daily3gp.com/vids/747.3gp"; // Working url = "http://www.ooklnet.com

Android playing resource files from internal storage causes MediaPlayer.prepare to give IOException

本秂侑毒 提交于 2019-11-26 23:09:17
问题 My app plays audio resource files from the internal directory designated for my app (/data/data/com...). It seems to download the files to that location okay, setDataSource(String path) doesn't throw any exceptions, but MediaPlayer.prepare() throws IOException.The same code works on the SD card. Why is this happening? EDIT: Let's assume this is the code; it's simpler than my code and it throws the same exception: package com.app.MediaPlayerTest; public class MediaTest extends Activity {

How to get Sampling rate and frequency of music file (MP3) in android?

耗尽温柔 提交于 2019-11-26 22:58:49
问题 I am developing audio player in android. So i want to add the details of the playing song i.e. Artist Name, Duration, Bit rate and sampling frequency. I can get Artist Name and duration of a music file by using MediaStore.Audio.Media library . But i am unable to get Bit rate and sampling frequency of the same file. So how can i get the same? As i know, it can be done by using native library. But don't know how? So anyone can help me on this? 回答1: You can approximate it by dividing the file

Android MediaPlayer Problems :“Error (-38 , 0) ” and “stop called in state 1”

十年热恋 提交于 2019-11-26 22:55:55
It's no sound from my device even the emulator. Actually, at the line "mMediaPlayer.create(this, musicIds[0]); " , eclipse suggests me two choices : "Change access to static using 'MediaPlayer'(declaring type)" or "Add @SuppressWarnings 'static-access' to on Create()" . By the way, I take eclipse's suggestions........but still don't work. P.S. I called a package from other project (pager). public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.diff_title); setContentView(R.layout.title_layout); viewFlow = (ViewFlow) findViewById(R.id.viewflow);