java,android,android-mediaplayer,voice-recording
I can't post this as a comment, but from what I know of audio, unless the speakers are far away from the microphone (like in earbuds or a gymnasium) or you will run the risk of creating feedback or recording audio you are playing again. EDIT: Ok I am assuming...
You can handle the error using onErrorListener on your MediaPlayer, like mp.setOnErrorListener(new OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { // handle your error here like exit media player or show message or move to next song return true; } }); Here, the main thing is...
android,android-mediaplayer,keyevent,android-audiomanager
dispatchMediaKeyEvent is inherited from AudioManager class. You're referencing it as a boolean. http://developer.android.com/reference/android/media/AudioManager.html#dispatchMediaKeyEvent(android.view.KeyEvent) This is how a code using this event should look like AudioManager am = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); long eventtime = SystemClock.uptimeMillis() - 1; KeyEvent downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, 0);...
android,android-studio,android-mediaplayer,music-player
You are re-creating the MediaPlayer upon every call of playPre(). You could change your code to this: public MediaPlayer mediaPlayer = null; public void playPre(View view) { if (mediaPlayer == null) { mediaPlayer = MediaPlayer.create(MainActivity.this,R.raw.music); } mediaPlayer.start(); ImageView pausaOneButton = (ImageView)findViewById(R.id.PausaOneButton); pausaOneButton.setVisibility(View.VISIBLE); } public void stopPre(View view) { mediaPlayer.pause(); ImageView...
Not an answer or solution, but without doing anything, it just suddenly started working again.
android,android-fragments,android-mediaplayer
You call getArguments() too early. You should initialize variable private Bundle bundle in some method. For example, in onCreate() public class NowPlayingFragment extends Fragment { private ArrayList<Song> songsList; private int position; private String PARCEL_KEY = "data"; private Bundle bundle; private DataTransferBetweenActivity data; @Override public void onCreate (Bundle savedInstanceState) { bundle...
android,video,android-mediaplayer,video-processing
Figured it out! (Well sort of.) On the android MediaPlayer there is a callback for OnVideoSizeChanged. I use that callback to adjust the UI to make sure the video aspect ratio displays correctly. For some reason, on the iOS videos, adjusting the size of video view was causing OnVideoSizeChanged to...
android,android-activity,notifications,android-mediaplayer
There are a lot of questions like this, but for my problem I have found a solution here, answered by Oderik.
android,android-mediaplayer,soundpool
Well it depends: Mediaplayer: Not good for simultaneous playing (you need multiple MP objects), the response time and especially the prepare() methode take a lot of time. Therefore synchronizing is quite impossible. SoundPool: Good for small MP3.files (size limt ~1mb, ~30sec) Easy to implement A lot faster than Mediaplayer. Mostly...
android,audio,timer,android-mediaplayer
You are looking for this: else if(timeLeft <= 42 && timeLeft > 27) { mp2.start(); } This will loop from 42 through 28 and thus once it ticks to 27 it will stop. For every condition inside an if statement you need to explicitly tell the compiler what two variables...
android,audio,parse.com,android-mediaplayer,audio-streaming
Finally I've got the solution! :) This was my mistake: byte[] data = outputFile.getBytes(); The object that I was trying to convert into a byte array (outputFile) was not the mp3 file, but the resource path of the file (/storage/sdcard0/audiocapturetest.mp3), so it was basically a string!If you want to save...
android,android-activity,android-mediaplayer
maybe with a handler? Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { playSound(); } }, 10000); ...
I am not sure what your problem is, but i believe you are trying to say that as you change through different activities, the sounds files do not stop playing In that case you can do the following In the activity You can override the onPause method and put mediaPlayer.stop()...
android,android-mediaplayer,illegalstateexception
The issue is not explicitly displayed but arises due to what is NOT in onResume(). By having the MediaPlayer created in onCreate(), after returning from onPause(), the activity does not go through onCreate() and thus there is no MediaPlayer. To resolve this issue, one would put the setup for MediaPlayer...
android,android-activity,android-mediaplayer
The code to close the activity was correct. The problem was in the Activity which launched the VideoFullscreenActivity. The offending piece of code was: <VideoView android:id="@+id/tag_attach_video" android:layout_width="150dp" android:layout_height="150dp" android:layout_marginTop="10dp"/> VideoFullscreenActivity did finish on calling onBackPressed(), but the VideoView in the earlier Activity was still active which necessitated pressing back again....
android,android-activity,android-studio,android-mediaplayer,samsung-mobile
I seem to have resolved the issue, I had the original sound file in *.wav format I used some music file converter I found online and used to convert it form *.wav to *.mp3 which drastically reduced it's size. Now it's working just fine even on my device.
android,audio,android-mediaplayer
You need to use MediaExtractor and MediaFormat to access the KEY_CHANNEL_COUNT Here is an example, MediaExtractor extractor = new MediaExtractor(); extractor.setDataSource(path); //where path is a String variable and points to the data source MediaFormat format = extractor.getTrackFormat(i); //where i is an int variable and denotes the index value of a...
java,android,android-fragments,android-mediaplayer,android-imagebutton
The statement is unreachable because you unconditionally return before it can be reached. The fix is simple: move return rootView to the end of the method and instead of getView() use rootView.
java,android,android-mediaplayer
These are the states currently declared in mediaplayer.h on the master branch of the AOSP: enum media_player_states { MEDIA_PLAYER_STATE_ERROR = 0, MEDIA_PLAYER_IDLE = 1 << 0, MEDIA_PLAYER_INITIALIZED = 1 << 1, MEDIA_PLAYER_PREPARING = 1 << 2, MEDIA_PLAYER_PREPARED = 1 << 3, MEDIA_PLAYER_STARTED = 1 << 4, MEDIA_PLAYER_PAUSED = 1 <<...
java,android,android-mediaplayer
You can solve this problem with randomly assign a value to numb1. double max = 10.0; // number of songs in the view. double min = 1.0; int numb1; b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { numb1 = (int)(Math.random() * (max - min) + min); e1.setText(String.valueOf(numb1)); nyc2(numb1); b.setVisibility(View.GONE);...
I've downloaded your app and, made a quick implementation of how I would do it with 3 Buttons, since I've noticed your bad english I also commented important parts in german : EDIT : Thanks to @Trinimon heres an even cleaner solution with just one MediaPlayer : // implement View.OnClickListener...
android,audio,android-mediaplayer
Use this method to play the sound private void play(String uriString) { // TODO Auto-generated method stub Uri uri = Uri.parse(uriString); if (uri != null) { // in order to play the ringtone, you need to create a new Ringtone // with RingtoneManager and pass it to a variable try...
android,android-mediaplayer,android-seekbar
Change seekBar.setMax(Assets.mediaPlayer.getDuration()); to seekBar.setMax(Assets.mediaPlayer.getDuration()/1000); ...
java,android,arrays,android-mediaplayer
See this : if(count < 3){ Main_Sound_mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { if(count <= 3){ try { AssetFileDescriptor afd = getAssets().openFd(a[count]); if (Main_Sound_mediaPlayer.isPlaying()==true ){ Main_Sound_mediaPlayer.stop();} Main_Sound_mediaPlayer.reset(); Main_Sound_mediaPlayer.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd .getLength()); Main_Sound_mediaPlayer.prepare(); Main_Sound_mediaPlayer.start(); }...
The easy fix is to simply add player.reset() in your play() method BEFORE calling player.setDataSource(...). You can only call setDataSource(...) once without resetting the player. It is legal to call reset() in any state however (even if the player isn't yet initialized). In other words, even if it's the first...
android,android-mediaplayer,music
I think it's beacuse the Xperias have a different Walkman App. I tested with this intent and it works: com.sonyericsson.music.playbackcontrol.ACTION_TRACK_STARTED The intent extras are different, the track info is on a Map, you need to debug it and see what you neeed. A manifest from a Xperia Walkman App( in...
android,android-fragments,android-mediaplayer
you can set volume for every mediaplayer. api
java,android,android-mediaplayer
try like this //set path mediaPlayer.setDataSource("yourFilePath"); mediaPlayer.setOnPrepareListener(new OnPrepareListener(MediaPlayer mediaPlayer) { mediaPlayer.start(); }); mediaPlayer.prepareAsync(); don't call start() without prepareAsync(); Hope it will solve your problem.....
android,io,android-mediaplayer
You can use MediaPlayer.create() in place of new MediaPlayer()/setDataSource() to easily create a MediaPlayer for a raw resource: mMediaPlayer = MediaPlayer.create(this, R.raw.t); ...
android,cursor,uri,android-mediaplayer,android-contentresolver
After searching around and trying the below examples, I was unsuccessful. @Jignesh Shaw's solution gave me an IllegalArgumentException when I would set the MediaMetadataRetriever's source and @Hanz Kratz's solution was only able to extract the song's duration (as he described) Between the two, however, I was inspired to come up...
android,android-mediaplayer,android-sdcard
Try passing the recorded file's descriptor to the setDataSource() method instead : File f = new File(myPath); if(f.exists()){ FileInputStream fis = new FileInputStream(f); FileDescriptor fileD = fis.getFD(); try{ mp.setDataSource(fileD); mp.prepare(); }catch(IOException e){ } mp.start(); } ...
android,nullpointerexception,android-mediaplayer,mediastore
Two options: the value of msg.getData() is NULL the value of msg.getData().getString(Constants.STRING_BUNDLE_KEY_PLAY_SONG) is NULL Attach a debugger or define some additional check to understand which is the real cause (1 or 2). UPDATE: you are passing some parameters in the wrong order! Change this: bundle.putString(stringPath, Constants.STRING_BUNDLE_KEY_PLAY_SONG); to this: bundle.putString(Constants.STRING_BUNDLE_KEY_PLAY_SONG, stringPath);...
You don't need to write your own AsyncTask to handle this, the MediaPlayer class already has a PrepareAsync method, which will handle background loading for you. Try something like this: package com.mypackage.test; import android.app.Activity; import android.media.AudioManager; import android.media.MediaPlayer; import android.os.Bundle; import android.view.View; import android.widget.Button; import java.io.IOException; public class MainActivity extends...
android,android-asynctask,android-mediaplayer,android-gridview
Check this out audioAdapter = new GridViewAudioAdapter(getActivity(), audioFiles); the above line audioFiles is an empty ArrayListand your audioAdapter is looking to it as his backup man.. Now in your retrieveAudio() method you add items to audioFiles like this audioFiles.add(audioGridItem); now audioFiles contains 1 item, -(suppose that is the only item...
MediaPlayer mediaPlayer; mediaPlayer = MediaPlayer.create(this, R.raw.sound); mediaPlayer.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { mediaPlayer.start(); } }); mediaPlayer.start(); Just start it in service private boolean isAppShown() { KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); boolean locked = km.inKeyguardRestrictedInputMode(); ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);...
android,android-mediaplayer,android-audiomanager
Ok it looks like the issue is Android 5.0.1's experimental MediaPlayer called NuPlayer. NuPlayer is being enabled by default on all Android 5.0.1 devices and is only disabled through Developer Options. I've filed a bug against Android here: https://code.google.com/p/android/issues/detail?id=94069&thanks=94069&ts=1420659450 Here's a sample email you can send your users when they...
Actually Media Player can't play samba share files( as per my knowledge ). So you have to select another way to play those files. I had solved this problem in this way, By using NanoHttpClient( 3rd party API ). This API(library jar file), you can get it from Google search....
Yes, you can use MediaSessionCompat with your custom media player,it will just works as a bridge between your application and the system for providing media metadata and media controls, it wont limit you in any way in how you actually play media.
class CustomMediaPlayer extends MediaPlayer { String dataSource; @Override public void setDataSource(String path) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException { // TODO Auto-generated method stub super.setDataSource(path); dataSource = path; } public String getDataSource() { return dataSource; } } Use this CustomMediaPlayer class instead to MediaPlayer to get the current url that is...
javascript,jquery,html5,android-mediaplayer,media
One way of doing that for smaller audio files is pre-loading the file as a blob: <button>play</button> <audio></audio> <script> var xhr = new XMLHttpRequest(); xhr.open('GET', 'click.mp3', true); xhr.responseType = 'blob'; var audio = document.querySelector('audio'); xhr.onload = function () { audio.src = URL.createObjectURL(xhr.response); }; xhr.send(); document.querySelector('button').onclick = function () { audio.play();...
android,android-mediaplayer,shoutcast
So I got it to work finally in the end....First of all, thanks to @TennyTech.com for the little hint. So to help ye people out, I will have an ans up on my github repo by tonight hopefully :) But do keep an eye out. Hope this helps, PatrickMelia...
Use MediaPlayer for it. Heres a code sample for playing song, here's a tutorial which explains how to do the rest of your need. To start song: MediaPlayer mediaPlayer = new MediaPlayer() MediaController mc = new MediaController(mediaPlayer); mc.setDataSource(Path); mc.prepare(); mc.start(); To Pause: mediaPlayer.pause() To Forward: int temp = (int)startTime; if((temp+forwardTime)<=finalTime){...
Try this static MediaPlayer startMusic; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cover); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); startMusic= MediaPlayer.create(Cover.this, R.raw.startgame); } @Override protected void onStart() { // TODO Auto-generated method stub if(!(startMusic.isPlaying())) { startMusic.setLooping(true); startMusic.start(); } super.onStart(); } @Override protected void onStop() { // TODO...
android,android-mediaplayer,scaling,textureview
If you want to scale the TextureView's contents, use setTransform(). For an example, see adjustAspectRatio() in Grafika's PlayMovieActivity class, which changes the size of the TextureView contents to match the aspect ratio of the video being played.
android-mediaplayer,runnable,seekbar,android-seekbar
After Searching a lot i have figured out a way to do this and since no one ha answered this question so to help others with same problem I am providing my solved java file code below- package com.musicplayer; import android.content.ContentResolver; import android.content.ContentUris; import android.content.Intent; import android.database.Cursor; import android.graphics.Bitmap; import...
java,android,android-fragments,media-player,android-mediaplayer
See, Singleton is a design pattern, and it is implemented by setting the default constructor as private, then you should provide a get method from wich you can recover your object instance. Check out the example bellow: public class Foo { private MediaPlaye md; private Foo () { md =...
android,onclick,media-player,android-mediaplayer,onpause
Just check if the MediaPlayer is null: if(mediaplayer != null) { mediaplayer.stop(); mediaplayer.reset(); mediaplayer.release(); } ...
android,eclipse,synchronization,android-mediaplayer
As nobody could help me i found a solution on my own! MediaPlayer will not fulfill my requirements!! Android JETPlayer in combination with JETCreator fulfill all my requirements. CAUTION: Installing Python for using JETCreator is very tricky, therfore follow this tutorial: http://www.tutorialspoint.com/android/android_jetplayer.htm And be carefull with the versions of python...
android,android-mediaplayer,error-code
From line 2881 of Android Media Player Source Code there are error code defined which description of Error Code occurred. In-case of MEDIA_ERROR_UNKNOWN "Unspecified media player error." is defined to indicate that there is no description available of the error....
android,uri,media-player,android-mediaplayer
just change your file:/... to file:/// and it will work Uri.parse(uri.toString().replace("file:/", "file:///")); or simply if you have a file try Uri.parse(String.valueOf(Uri.fromFile(myFile))); Actually the thing is that the media player requires MRL followed by your path to file EDIT I have answered a question on how to initialise MediaPlayer using Uri...
android,android-studio,android-service,android-mediaplayer,android-intentservice
You can also use any timer idea but what I would do most likely is encapsulating the beep in a separate Runnable class and then will call it from my activity/fragment/view whenever it is needed. public final class BeepRunnable implements Runnable { private final MediaPlayer mediaPlayer; private final View view;...
As pointed out @TuomasK you release the media before playing it. You should implement OnCompletionListener to release MediaPlayer properly. You can do it like this: MediaPlayer mMp = MediaPlayer.create(ShapesActivity.this, R.raw.circle); mMp.start(); mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { public void onCompletion(MediaPlayer mp) { mp.reset(); mp.release(); }; }); ...
android,media-player,android-mediaplayer
try this when you create MediaPlayer object and start player you need to release it when music Complete. MediaPlayer mp; mp = MediaPlayer.create(getApplicationContext(), R.raw.sound); mp.start(); mp.setOnCompletionListener(new OnCompletionListener() { public void onCompletion(MediaPlayer mp) { mp.release(); }; }); } ...
java,android,eclipse,android-actionbar,android-mediaplayer
1.Please initialize mp = new MediaPlayer(); in your onCreate() method @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); play(null);//you are calling play by launching } 2.change it to boolean isPlaying = false; because when app start it set as boolean isPlaying = false so it will play the audio and...
android,android-service,android-mediaplayer,surfaceview
you missed in onStop: @Override protected void onStop() { holder.removeCallback(this); super.onStop(); } please add the crash report ...
java,android,android-mediaplayer,countdowntimer
There are lots of reports of Android MediaPlayer stutter with various ways to try to fix it. This seems to be the best related question: MediaPlayer stutters at start of mp3 playback However, AudioTrack might be better for your particular situation where you just want to play specific notes. See:...
android,android-intent,android-service,android-mediaplayer
However, I'm wondering what's the point of doing this? To have the service be running, to tell the OS "hey, we are doing work here on behalf of the user, please let my process live a bit longer". This is covered in the documentation. Do we have to send...
java,android,android-intent,android-fragments,android-mediaplayer
You can use the Singleton Pattern: public class Singleton { private static Singleton mInstance = null; private String mString; private Singleton(){ mString = "Hello"; } public static Singleton getInstance(){ if(mInstance == null) { mInstance = new Singleton(); } return mInstance; } public String getString(){ return this.mString; } public void setString(String...
java,android,android-mediaplayer,text-to-speech
The method synthesizeToFile is asynchronous thus you should do the checking File fileTTS = new File(destFileName); if (fileTTS.exists()) { Log.d(TAG, "successfully created fileTTS"); } else { Log.d(TAG, "failed while creating fileTTS"); } in onUtteranceCompletedListener or UtteranceProgressListener...
android,fragment,android-mediaplayer
You can stop your MediaPlayer from streaming in onPause() method of the fragment. This will stop the mediaplayer when you open the other fragment or you destroy the fragment...
java,android,android-intent,android-fragments,android-mediaplayer
You can use singleton pattern, like this: public class MediaPlayerSingleton extends MediaPlayer{ private static MediaPlayerSingleton mediaPlayerSingleton; private MediaPlayerSingleton() {} public static MediaPlayerSingleton getInstance() { synchronized (mediaPlayerSingleton) { // if you'll be using it in moe then one thread if(mediaPlayerSingleton == null) mediaPlayerSingleton = new MediaPlayerSingleton(); } return mediaPlayerSingleton; } }...
android,media-player,android-mediaplayer
Thanks so much to this answer on SO, and despite the fact that the URL insisted its Content-Type was media, I parsed it like it was a text file and found out that it was a text file--basically, a playlist containing a link to the actual media stream. For anyone...
android,video,android-mediaplayer,videoview,playback
You could be checking for it's current position in a handler like this private android.os.Handler mHandler; private Runnable mRunnable; mHandler = new Handler(); mRunnable = new Runnable() { public void run() { int currentPostion = mVideoView.getCurrentPosition()); if(currentPostion >= 30 * 1000 || currentPostion == mVideoView.getDuration()) { // Play next video...
android,audio,android-mediaplayer
The problem is in this code: @Override public void onTick(long millisUntilFinished) { long timeLeft = millisUntilFinished / 1000; Timer.setText("" + String.format("%d min, %d sec", TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished), TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished)))); if (timeLeft >= 43) { mp = MediaPlayer.create(getApplicationContext(), R.raw.beeb1); mp.start(); } } Right now, on every "tick" (1000 ms) it is creating...
The second one is told length (and offset) while the first one plays as long as the file descriptor returns some data. Resources are usually stored in an archive so reading from the file descriptor continues past the first song where it finds the second song and then the third...
android,datasource,android-mediaplayer
Firstly- Check that the SD card is mounted and readable. if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)); or if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED_READ_ONLY)); From your question here: You are using: File file =new File(Environment.getExternalStorageDirectory(),"A.mp3"); mediaPlayer.setDataSource(file.getPath()); and have tried: mediaPlayer.setDataSource("/storage/sdcard1/A.mp3") Then try: Edit: add in Music folder. mediaPlayer.setDataSource("/sdcard1/Music/A.mp3");...
android,android-mediaplayer,glsurfaceview
It might be easier to do this with a plain SurfaceView, handling the EGL setup and thread management yourself. There's little value in having a dedicated rendering thread if you're just blitting the video frame. (See Grafika for examples.) If you do stick with GLSurfaceView, you don't want or need...
I think the problem here is that you need to set the listener before you call player.prepareAsync(); because there is always the possibility (especially if the url points to the disk) that the prepareAsync call might return before the listener is set.
java,android,unity3d,android-mediaplayer
It would appears that while i have found nothing explicitly states that this CAN be done, there is no real information or any examples of it having been done before. I'll be attempting a re-working of this in native C++ code....
java,android,url,uri,android-mediaplayer
Following code will be use to play url using media Player: String radioUrl = "http://s26.myradiostream.com:9406/listen.pls"; mediaPlayer = new MediaPlayer(); mediaPlayer.setDataSource(radioUrl); mediaPlayer.prepare(); mediaPlayer.start(); ...
android,android-activity,broadcastreceiver,android-mediaplayer
I have been solved this issue by using one separate class in that i have written startRinging(context) and stopRinging(),and i am calling startRinging from my Receiver and stopRinging from my Activity class then it is working properly.
java,android-studio,android-mediaplayer
Just start it when you are in that Activity, setLooping to true, and when the user leaves the screen destroy the mediaPlayer in Activity.onDestroy(and maybe onPause depending on what you want to accomplish) method. Remember it is important to destroy a mediaPlayer when you're done with it as it consumes...
Better declare the media player as a field and create it only once in your onCreate() not in onDraw(). Right now, everytime onDraw() is called(which is usually a lot) you create a new Media Player, that eats up resources. Also good to do is mySound.pause() if its not needed and...
Out of bounds exception, because there is no mSound[3], only 0-2, total 3 elements. void nextTrack(int i) { mSound = new int [] { R.raw.error_one, R.raw.error_two, R.raw.error_three }; mp = MediaPlayer.create(getActivity(), mSound[i % 3]); mp.start(); } You can use i % 3 to replace i in nextTrack method, so the...
You need to register 2 listeners (on completion and on error) and then you would need to delay next play in on completion callback. Reason for the error listener is to return true to avoid calling on completion event whenever there is an error - explanation here private final Runnable...
android,performance,media-player,android-mediaplayer
As an answer, 2nd option looks fine to me, as there is no need to have multiple MediaPlayer instance instead its better to manage with single instance of MediaPlayer. Currently, I am working on an application which plays list of videos one by one and for that I am using...
android,android-mediaplayer,avaudioplayer
Their have may solution according to your question method-1 simply you can override on touch method by touching sound is started. @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mPlayer.setLooping(true); mPlayer.start(); break; case MotionEvent.ACTION_UP: mPlayer.pause(); break; } return true; } //or public boolean onTouch(View v,...
android,android-mediaplayer,mediacontroller
ACTION_DOWN will provide you with the next available child action in the hierarchy. However, I think you meant ACTION_UP, which takes you to the parent screen. You should also try putting finish() before the if statement.
android,metadata,android-mediaplayer,avrcp
I'm using 5.0 Then RemoteControlClient will not work. Does this mean it doesn't work at all? Correct. Quoting the documentation: Lock screens in Android 5.0 do not show transport controls for your MediaSession or RemoteControlClient. Instead, your app can provide media playback control from the lock screen through a...
Create failed, so it returned null. You didn't check for this, so when you call mp.start you crash. First off, you should check for mp.create returning null and not call start if it does. Secondly, you can't do strings like that. R.raw.xxx is NOT a filename. Its a resource id,...
android,string,android-studio,android-mediaplayer
In your activity: getResources().getResourceEntryName(int resid); or getResources().getResourceName(int resid); ...
You can use the method selectTrack and getTrackInfo Therefore, it doesn't work properly for all devices and Android OS version. It might be helpfull to use ExoPlayer . Here you can check the demo app....
As per the documentation, you need to re-prepare the MediaPlayer (emphasis mine): Once in the Stopped state, playback cannot be started until prepare() or prepareAsync() are called to set the MediaPlayer object to the Prepared state again. ...
android,media-player,android-mediaplayer,back,onbackpressed
I don't use service but still I have not understood why s3 kills activity. But I found a solution . I change my super.onBackPressed() to moveTaskToBack(true);. And I added this option to manifest file in activity tag(Main) android:noHistory="true". Anymore when I pressed back key MediaPlayer isn't stopping stream. Maybe this...
The correct way to play a sound is to use it's ID and not the name: cursor.getInt(RingtoneManager.ID_COLUMN_INDEX) Thanks Darkie for pointing me to the right direction....
android,android-intent,android-service,android-mediaplayer
In your activity do the following: Intent i = new Intent(this,PlayMusicService.class); i.putExtra("action","com.example.neotavraham.PLAY"); startService(i); In your service do the following: package com.example.neotavraham; import android.app.Service; import android.content.Intent; import android.media.MediaPlayer; import android.os.IBinder; import android.util.Log; public class PlayMusicService extends Service { public static final String ACTION_PLAY = "com.example.neotavraham.PLAY"; MediaPlayer mMediaPlayer = null; @Override public...
Well, due to documentation, this method is "called to update status in buffering", so when you reach 100%, buffering status shouldn't updated anymore (it makes sense, am I right?). Unfortunately, there is a disease, which consumes process of developing software for Android platform - OEMs modify this platform due to...
android,android-asynctask,inputstream,android-mediaplayer,runnable
I got it. I have used a TimeTask, which calls a method UpdateGUI(); in every 10 Seconds. This method "UpdateGUI();" further calls a method "getHTML();" which load webpage's content to String text. Also this method calls myRunnable via myHandler at myHandler.post(myRunnable); and myRunnable set the text of textView txtMessage To...
android,button,audio,click,android-mediaplayer
Currently in your XML you have a TextView, you should add a Button (actually you can just change TextView to Button in this case). After that you need to either add android:onClick="onClick" under the button. Or you can use a onClickListener for the button....
android,android-mediaplayer,surfaceview
I got the solution as I put my class GameView extends SurfaceView inside another class Game extends Activity that enables me to use onBackPressed() method . @Override public void onBackPressed() { mp1.stop(); Intent i=new Intent(this,MainActivity.class); startActivity(i); } Thank you everyone for your best efforts to solve my problem....