I am trying to play the mp3 file from web using media player class , on some devices it is working fine but for few devices it is giving following error .
QCMediaPlayer mediaplayer NOT present
Unable to create media player
error (-38, 0)
Attempt to call getDuration without a valid mediaplayer
any help on this will be of great help.
In general error -38 means you are trying to call a function in wrong state for the player.
In your case as error says, you call getDuration() when player is not prepared or started. Set setOnPreparedListener() then start the player mp.start(), then you can call getDuration().
Check this Tutorial to stream audio from web
Related
I am using webrtc for video calling in android. I am simultaneously screen recording after call is connected in sender end. I am getting this error log in sender end. Receiver end voice is not hearing when screen recording is started using MediaRecorder. I think webrtc is not streaming audio to receiver end when media recorder is started using microphone.
Error
AudioRecord: start() status -38
2020-06-25 13:37:18.948 3276-5257/com.obs.booking E/WebRtcAudioRecord: WebRtcAudioRecord: Start recording error: AUDIO_RECORD_START_STATE_MISMATCH. AudioRecord.startRecording failed - incorrect state :1
2020-06-25 13:37:18.949 3276-5257/com.obs.booking E/AudioRecordJni: StartRecording failed!
2020-06-25 13:37:18.949 3276-5257/com.obs.booking E/libjingle: (voe_base_impl.cc:439): StartSend: Failed to start recording
2020-06-25 13:37:18.949 3276-5257/com.obs.booking E/libjingle: (voe_base_impl.cc:386): StartSend() failed to start recording
2020-06-25 13:37:18.949 3276-5257/com.obs.booking E/libjingle: (audio_send_stream.cc:245): AudioSendStream::Start failed with error: -1
Help me out to resolve this error.
The error message indicates that the audio recording is failed due to incorrect state.
This error "AUDIO_RECORD_START_STATE_MISMATCH" tells that when the start() methods is called the audio recording already is in progress.
It is possible there is a conflict between media-recording and WEBRTC audio recording.
To solve this there are several ways that I hope be useful:
1 - make sure the source of both are same.
2 - Try to stop webRTC before start the media-recorder
I'm making an Android audio visualizer app for streaming Spotify music. I'm using Spotify's android-streaming-sdk which creates a local service (no need to have the Spotify app installed) and it plays music from within the app. I'm having a difficult time getting Androids Visualizer library to pick up any audio from Spotify (it works fine if I use a local .mp3 file).
//Start playing spotify track
player.playUri(MainActivity.operationCallback,
VisualizerModel.getInstance().getTrackURI(), 0, 0);
.... other code ....
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
int audioSessionId = mediaPlayer.getAudioSessionId();
visualizer = new Visualizer(audioSessionId);
visualizer.setCaptureSize(audioSampleSize);
visualizer.setDataCaptureListener(this, Visualizer.getMaxCaptureRate(), true, true);
visualizer.setEnabled(true);
If I run this, everything compiles and runs okay, but the visualizer does not pick up any audio. This makes me thing that the audio sessionId is not the same one as Spotify is playing on. However, if I switch the audioSessionId to 0 (which should listen to all the audio sessions mixed from what I understand) it crashes with this error:
E/AudioEffect: set(): AudioFlinger could not create effect, status: -1
E/visualizers-JNI: Visualizer initCheck failed -3
E/Visualizer-JAVA: Error code -3 when initializing Visualizer.
According to their documentation that error means: Operation failed due to bad object initialization.
I'm targetting API 24 (Android 7.0).
Please let me know if you have suggestions or an alternative to using Android's Visualizer library. I feel like my main problem is that I'm not sure how to find the audioSessionId that Spotify is playing on, and because Spotify's android-streaming-sdk is in beta (and not mentioned on their website) there is virtually no documentation on it from what I can see on Github.
Thank you for taking the time to read my issue!
I was facing the same error. Adding "android.permission.RECORD_AUDIO" to manifest and requesting for runtime permissions fixed the issue.
to protect privacy of certain audio data (e.g voice mail) the use of the visualizer requires the permission android.permission.RECORD_AUDIO
Also
Creating a Visualizer on the output mix (audio session 0) requires permission Manifest.permission.MODIFY_AUDIO_SETTINGS
Android docs for Visualizer class
I have an AudioRecorder app that runs in a service smoothly, but when I try to use any Recorder app (Video/Voice Recorder), it gives the following error
Voice: Unable to start a new recording. Other applications are already recording
Video: Recording failed
a similar issue was raised here
I want to know if there is any possible way to set a service to listen to when a MediaRecorder.start() is being called by ANY app or even when the object is created.
Thanks.
In WebView when I play a YouTube video it plays the video successfully but it gives following error message :
OnBufferingUpdateListener is null. Failed to send MEDIA_BUFFERING_UPDATE message.
Even if I finish this activity the video stops but still the above error continuously occurs.
When I open another activity and tried to play video in videoview control then it gives error message
Can't play video. and following error code -
E/MediaPlayer(10207): Error (-38,0)
Is there any way to solve these problems?
I am trying to stream an MP3-file with the following code in Android 2.3.3:
player = new MediaPlayer();
String uri = "http://192.168.2.102:8080/sound/test.mp3";
player.setDataSource(uri);
player.prepare();
for some reason every time I call prepare I get the following IOException: java.io.IOException: Prepare failed.: status=0x1
I tested the link directly in a browser and it works.
I also added the Internet permission in the manifest.
Anyone know what I am doing wrong?
thanks for the help
It seems like the problem was that there was no ID3 tag attached to the MP3 file I was trying to stream, and Android doesn't like that...