recently, I've been trying to create a visual recorder and player inside my android application, I want it to be like the SoundCloud sound waves.
so far, I've created one for the recorder using a customized view that makes lines after the last one with the height that would be given by mediaRecorder.getMaxAmplitude each 100ms.
the problem is that, unlike MediaRecorder, MediaPlayer doesn't have getMaxAmplitude, so when users play recorded files they won't see sound waves correctly.
However, I tried to search about this but the answer that I found was not the right one, It just gives me the volume level of the user's mobile.
thanks to anyone who could help to solve this problem.
Related
Can we reset all the values that hold in mediaRecorder while recording video?
I've tried just using mediaRecorder.reset() while recording video. But it won't work. I don't know is it possible or not. If it is possible please any references will appreciate.
I've read this and also google developers, mediaRecorder in developers. But any of references didn't mention my issue.
EDIT :
What I want is while recording a video set mediaRecorder.reset() and mediaRecorder.start(). The problem occurs when I'm doing this. I need to chunk of video clips while recording the same video. Need those process in parallel. While I'm trying to stop and restart the camera capturing methods it will miss many frames. Bcoz handling camera is somewhat cost for the processor. I tried this and it occurs some errors that telling session configuration failed. Now I'm stuck in here. Need help!
Thank you for your valuable time.
Edit in response to clarifications:
Ok, so you want to split the video file into multiple separate files.
You'll need to use the lower-level APIs (MediaCodec, MediaMuxer) to implement this yourself; the higher-level MediaRecorder does not support this without losing frames.
Original:
So you're trying to pause the video recording temporarily.
Unfortunately, there's no support for this before API level 24, which added MediaRecorder.pause(). You can't call MediaRecorder.reset() mid-video and have it work.
All you can really do is to record the full video and then post-process it to crop sections you don't want.
I was hoping someone can help me understand an issue I am seeing with the Mediaplayer class.
I am creating a music app that needs to play two music files at the same time. In one of the use case scenarios I want to be able to play an MP3 track and then initiate another MP3 to start playing at a differnt volume over the top of the first.
I have found that the Android mediaplayer class offers this functionality and have created a test application to do this by simply creating two instances of mediaplayer.
For example...
MediaPlayer mMediaPlayer1,mMediaPlayer2;
mMediaPlayer1 = new MediaPlayer();
mMediaPlayer2= new MediaPlayer();
The problem I am having is that in the emulator it works fine and on most devices I try it works fine but on a few test devices I get odd results when I try to start the second mediaplayer/track.
What happens is that the volume of either the second or the first audio track suddenly reduces to nothing. I can see that the mediaplayer is still "playing" as I have several progress bars setup to track its progress but you can't hear anything.
I've seen this on both a OnePlus One and a OnePlus X phone. On my Asus Tablet and a Smasung A3 phone it works fine though. Its not related to the OS version either as I've tried it on 4.4.2, 5, 6 and 7 with mixed results. It definitly seems to be hardware related.
I've also seen related posts describing this issue but none so far with an answer as to what is causing it.
Can anyone explain this or shed any light on the problem? Even if it is only to understand the limitation of what I am doing?
FYI - I did look at Soundpool but can't use it becuase the clips I am using are bigger than 1Mb.
Thanks in advance...
For your goal mixing music you can develop your own "mixer" which will work with raw audio data.
Steps are:
extracting encoded audio data from a music file by MediaExtractor
decoding these ByteBuffers by Decoder (MediaCodec)
mixing one decoded buffer from first audio with one decoded buffer form second audio to get one mixed buffer, here is algorithm
playing the mixed buffer by AudioTrack
Here is a lot of work but it will work anywhere!
Thanks for the suggestion. In the end found a way round it. If you use the newer AudioAttributes option (API 21 and above) and set the FLAG_AUDIBILITY_ENFORCED flag it then seems to force the devices I was having issues with to play the streams.... thanks for looking folks!
I am currently trying to implement android voice recognition for a research project that I am currently working on. I was able to follow a guide and I am able to correctly receive input but I want the phone to continuously look for input instead of telling me to try again after a while. I want to use it to control a moving robot connected to the phone meaning that I won't be able to physically touch the screen. Right now I made it so that if speech is recognized and converted then it immediately calls promptSpeechInput() again but I can't seem to find a way to do that when it runs out of time.
I want to know if it is possible to access the audio that is currently playing on the Android device.
Example: if Spotify is running in the background, I want to access the audio to control some LEDs that are connected to my RaspberryPi.
I want to create some sort of equalizer that changes colors depending on the sound that is currently playing. I appreciate if some one could tell me if accessing the main audio output is possible or not.
Unless you are using a rooted phone, it's not possible to capture output of a random app on Android.
You can however create an app that plays media files and captures the output for the purpose of visualization with "Visualizer" effect. You can take a look on the sample here: https://android.googlesource.com/platform/development/+/master/samples/ApiDemos/src/com/example/android/apis/media/AudioFxDemo.java
(look for "Visualizer").
If you are using Raspberry Pi anyway, you can just play all your music through it, capture and analyze it there. You will need an external USB sound card though. See for example this post: http://www.g7smy.co.uk/2013/08/recording-sound-on-the-raspberry-pi/
There they just record and play audio back, but you can insert an analysis phase in between.
I've read somewhere that it isn't still possible to record Audio while using the Camera function on Android phones. But this source was kind of outdated.
I've also read, that this is possible on Iphone.
But I need this function for Android to create an App.
Can anybody say more to that?
Is there a possibility on Android to archive that in an Application?
I don't see why not. They don't share the same hardware. Even if not, you could easily fake it by recording video (which also records sound) and just taking the first still image of the video as your photo.