Android :: Calling The Stop() Function Of MediaPlayer
Aug 22, 2010
I see calling the stop function of MediaPlayer simply does nothing. The playback goes on.
I looked in the documentation and I found: "Stops playback after playback has been stopped or paused."
So, I tried to pause() it before stopping, but the MediaPlayer then pauses and resumes the playback. The only thing I can see is that the buffering stops. But the playback continues. Is this the expected behavior? Could the problem be related to the fact that I call the methods of the MediaPlayer object from different threads than the creator by synchronizing with Semaphores?
View 6 Replies
Apr 27, 2009
I have a requirement to play several sounds many times in my game so instead of creating the MediaPlayer again and again I have called mp.seekTo(0) in onCompletion(mp) so that it will restart. Sometimes the sound is not audible from the device when I call mp.start () after setting mp.seekTo(0); but the player calls onCompletion() without playing any sound, this is observed randomly on most of the sounds
My sounds are of short duration mostly less than a second.
I am using a separate MediaPlayer for each sound (as I need this) -
There are almost 28 sounds in my game so i will be creating 28 MediaPlayers.
Below is the attached code for player
Also If I try to play many sounds one after the other in a short period of time i get an error saying "no more track names available". can u tell Why this is happening...?
check the below code:
CODE:........
View 9 Replies
View Related
Jul 21, 2009
I develop a music play app, whe app framework is:
list.java->play.java
eg: in the list.java there have two mp3 files : 1.mp3,2.mp3 when first time choose 1.mp3, then play ok, then back to list.java from play.java, and now the 1.mp3 is still playing, and then i click 2.mp3 in the list.java, and go to play.java, but it play 1.mp3 and 2.mp3 simultaneously? but i have used the mediaplayer.stop(); mediaplayer.release(); and it always play 1.mp3 and 2.mp3 simultaneously? i want stop 1.mp3 and play 2.mp3.
View 7 Replies
View Related
Jun 8, 2010
I know that when a row is selected in list view, the function on List Item Click() is called. I want to know which function is called when a row in List View is highlighted(not selected).
View 1 Replies
View Related
Apr 20, 2010
I have a SMSReceiver class that needs to pass the phone number and message to another class. Which works but when I call that class I need the function to read preference to compare if it needs to execute another function.
View 2 Replies
View Related
Jun 24, 2010
Is there a way to hide my phone number when calling out? I came over from BlackBerry, where there is simply an option to "hide" my phone number on outgoing calls... but I can't seem to do this with my Eris. Someone once suggested that I prefix my contacts with *69... but that seems to prevent caller id from working properly, which just trades one issue for another.
If possible, I would prefer to be selective with who I do this with (it's okay for personal contacts to see my number... but it's not okay for business contacts to see my number).
View 9 Replies
View Related
Sep 17, 2010
My android app creates a MediaPlayer() and plays a looping song. I need to have it stop playing when the user leaves the app. I also need to get at the volume buttons somehow, to let users adjust the songs volume...
CODE:..................
View 1 Replies
View Related
Feb 16, 2010
Can anyone tell me how to stop media player that was started in a previous activity?For ex. In activity-1 button pressed that did - mp.start(); then activity-2 starts for different layout with new buttons, then when button pressed, mp.stop is called, but does not stop the media from the first activity.
View 4 Replies
View Related
Jun 3, 2010
I'm playing around with the MediaPlayer class to reproduce some sounds/music. I am playing raw resources (res/raw) and it looks kind of easy.
To play a raw resource, the MediaPlayer has to be initialized like this:
CODE:.................
Until here there is no problem. The sound is played, and everything works fine. My problem appears when I want to add more options to my application. Specifically when I add the "Stop" button/option.
Basically, what I want to do is...when I press "Stop", the music stops. And when I press "Start", the song/sound starts over. (pretty basic!)
To stop the media player, you only have to call stop(). But to play the sound again, the media player has to be reseted and prepared.
CODE:...............
The problem is that the method setDataSource() only accepts as params a file path, Content Provider URI, streaming media URL path, or File Descriptor.
So, since this method doesn't accept a resource identifier, I don't know how to set the data source in order to call prepare(). In addition, I don't understand why you can't use a Resouce identifier to set the data source, but you can use a resource identifier when initializing the MediaPlayer.
I guess that I'm missing something. I wonder if I am mixing concepts, and the method stop() doesn't have to be called in the "Stop" button.
View 4 Replies
View Related
Apr 17, 2009
I am calling a method of another .apk file dynamically at runtime in my application. I can execute it successfully if method does not contain any variable which is defined outside of that method.
But if I am using the variables which are defined outside that method ( in the same activity or same .apk) then my application throws "java.lang.reflect.InvocationTargetException" at runtime.
For e.g. if method defines as ,
COE:...................
View 14 Replies
View Related
Nov 18, 2009
I have a activity which is called from another activity as an intent... This activity loads and starts playing a audio file. All is good - that much works. The activity also has a "stop" button and that stops the audio from playing - that is also fine.
But how do I stop the file from playing if the user uses the back button to leave the activity without clicking on the "Stop" button?
View 3 Replies
View Related
Aug 8, 2010
So ya, there's a phone in my HTC Hero. No surprise.
My problem is this:
I find that the easiest way to call a person is to go to the phone app and scroll through the call history displayed to find the person I wish to call. Once I see their name, I just press on it, and the call begins. Unfortunately, a friend I call often may use their house phone or cell phone when I only ever want to call their cell (Evo ). Often, the situation is that I previously talked to him on his house phone, and I'm calling him in the middle of the night (we're young; we don't sleep rational hours during the summer... or ever). Unfortunately for me, my call usually bugs his parents, and I get reprimanded...
Is there a setting that allows me to only call his cell, or do I just need to break this habit?
View 9 Replies
View Related
Jul 2, 2010
I am trying to call my service class's stopService() method from my activity. But I don't know how to access stopservice method from my activity class. I have the below code but its not working. This is HomeScreen class:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
enablecheck = (CheckBox)findViewById(R.id.enablecheck);
enablecheck.setOnCheckedChangeListener(new OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
if(enablecheck.isChecked()){
startService(new Intent(HomeScreen.this, AutoService.class));
} else {
stopService(new Intent(HomeScreen.this, AutoService.class));
} } });
}
This is Service Class:
public class AutoService extends Service {
private static final String TAG = "AutoService";
private Timer timer;
private TimerTask task;
@Override
public IBinder onBind(Intent intent) {
return null;
} @Override
public void onCreate() {
Toast.makeText(this, "Auto Service Created", Toast.LENGTH_LONG).show();
Log.d(TAG, "onCreate");
int delay = 5000; // delay for 5 sec.
int period = 5000; // repeat every sec.
timer = new Timer();
timer.scheduleAtFixedRate(task = new TimerTask(){
public void run() {
System.out.println("done");
} }, delay, period);
}
@Override
public boolean stopService(Intent name) {
// TODO Auto-generated method stub
timer.cancel();
task.cancel();
return super.stopService(name);
} }
View 3 Replies
View Related
Jan 5, 2010
I have a ListView displaying images on every element of the ListView, It works fine... but when I start to scrolling I have realized my image is downloaded again if it is displayed in the screen of my phone device!
How could I stop reloading the images or all the content of the in ListView again?
Or how could I avoid reading the getView() function again If I have already downloaded all its content?
View 5 Replies
View Related
Aug 7, 2010
Please stop calling Captivate as Cappy! I get anger sharks swimming in my head...
View 11 Replies
View Related
Oct 12, 2011
am trying to call a class from the main and am getting an error and the program is stop working. am trying to call from the main.class the test.class
on the main i have write the following code
Intent connectIntent2 = new Intent(Conn.this, Test.class);
startActivity(connectIntent2);
and on the test.java i have write[code]....
the R.id.button_scan is been define in the main.xml and i just want to make it invisible.
View 1 Replies
View Related
Nov 28, 2010
The screen of xperia mini pro is quickly turn off when calling and i have to spend 5 second before touching the screen again to hang up.
View 2 Replies
View Related
Sep 30, 2009
Had a few days of use without issues, go to make a call yesterday and it takes ages to connect, but instead of connecting I get a beep and then it returns me to my contact list. Tried putting the phone in and out of flight mode by holding down the power button and selecting the flight mode option, the option turns grey after I press it, won't allow me to press it again and seemingly does nothing. Press the off option and turn the phone back on and it's fine. Now I reckon I had suffered this with earlier firmwares.
View 26 Replies
View Related
Jan 5, 2010
In my application i have several activities and i want to start background music whenever my *Application* is launched and stop music whenever *Application* is paused or stopped.
View 4 Replies
View Related
Apr 7, 2009
How to play the file which is present in MY computer For Eg : Path="D:/Vinod/Songs" can any body give the way to play the audiao file from files in system .....
View 3 Replies
View Related
Oct 20, 2009
In 1.6 I do the following to stream an mp3 shoutcast stream:
CODE:...........
This works great. However, I have to support phones running 1.5 as well. When I build against the 1.5 libraries and run in a level 3 emulator, I get an exception on the prepare() call with the message: Prepare failed.: status=0x1.
Is this supported in 1.5. Is there some other mechanism I have to use that will work in both?
View 11 Replies
View Related
Aug 10, 2009
I have such code:..............
When my sound played for the first time, it's all fine. But when for second, third, etc.. it sounds like cutted, just little part of my "click.wav". If I put there sound in another format like mp3 or ogg - all just fine.
Or if I write like this: mp_click = MediaPlayer.create(CubeTest_Main.Context, R.raw.click); mp_click.start(); All if fine too, but this is a bit slow, becouse this sound is playing very often.
View 5 Replies
View Related
Aug 1, 2010
I have a program with a function copied below it plays a sound upon clicking a button. If you click the button 10 times 10 different media players play the same sound that is the way i want it but how can i assign a button to stop all 10 media players at a time like a "STOP ALL BUTTON"
CODE:..............
The code above only stops the last instance of mp.
View 1 Replies
View Related
Mar 3, 2009
I am developing a media player application which downloads from internet and plays. so while downloading I want to show a progress bar saying "buffering...", and while playing I want to dismiss the same progress bar. I can display the progress bar while downloading (by implementing the listener onBufferedUpdateListener), how can I get the event for player while it is playing.
View 6 Replies
View Related
Jan 20, 2010
Attached is my code, I cannot see the video while playing a MPG file.
CODE:................
View 6 Replies
View Related
Apr 26, 2010
This is my script:
CODE:..................
View 5 Replies
View Related
Jun 19, 2009
a mp3 file which can be played well in sdcard. but when i copy it to another subarea in linux linked as /data/test. but i can not be played in that directory
View 2 Replies
View Related
Jul 7, 2010
We are seeing some very strange results in media playback on HTC EVO devices.
In our call to MediaPlayer.create(getApplicationContext(), uri), we get failures with the following stack trace:
CODE:..................
This code works just fine for many, many thousands of other devices out there.
View 4 Replies
View Related
Feb 17, 2009
I am developing a media player which will download the media content from network (Shoutcast) It works fine. Problem is a small gap between players (2 players) I am using two mediaplayers to play the data while a thread downloads and stores the data and stores in to 100Kb files continuously. on first players oncompletelistener() i started the second player wise versa. I think there is a problem with mp3 frames(header sync byte) while splitting 100kb files. how to resole the gap between players.
View 2 Replies
View Related
Mar 18, 2009
I know this question has been asked previously because I have read the other postings over a hundred times but yet I cannot come up with an answer on how to use keep a MediaPlayer object playing over an orientation change. I've read that you can use onRetainNonConfigurationInstance() to pass an object to your future self when the activity is destroyed/recreated, but I can't keep a video playing in this circumstances. Does anybody have an example or an advice/guide on how to do this? or rather what do I pass on onRetainNonConfigurationInstance() to keep the video playing after an orientation change?
View 3 Replies
View Related