I was using audiotrack to play some sounds in a loop. Now I need to know in which period of time I'm right now, so i decided to use setPositionNotificationPeriod which works quite good.
The problem is that it just work for the first "loop" but stop being called after that :\
The code looks like the following:
...
audioTrack.setPositionNotificationPeriod(bufferSize/numCalls);
audioTrack.setPlaybackPositionUpdateListener(this);
audioTrack.setLoopPoints(0,bufferSize,-1);
...
public void onPeriodicNotification(AudioTrack track)
{
Log.d("Hey I'm on call: "+numCall++);
}
With that I got just #numCalls# calls but I want them to be forever.
Any idea how to fix it?
Thank you very much
EDIT: I forgot to say I'm using an static audiotrack instead of stream
Related
The demand is that saving a video frame in the video call. I have made a demo that take a screenshot through the GLSurfaceView's method "onDrawFrame". But when I use the webrtc, it have its own renderer "VideoRendererGUI" .And then when I want to override it, I find it can't be overrided. the main part code :
vsv = (GLSurfaceView) findViewById(R.id.glviewchild_call);
vsv.setPreserveEGLContextOnPause(true);
vsv.setKeepScreenOn(true);
VideoRendererGui.setView(vsv, new Runnable() {
#Override
public void run() {
init();
}
});
And If you have another way to take a screenshot, you can also share with me.
Thanks a lot!
If you use a SurfaceViewRenderer to display the stream, you can use the solution in this answer to capture a frame on the call.
Basically, using surfaceViewRenderer.AddFrameListener with a class that implements EGLRenderer.FrameListener
I will assume that the SurfaceViewRenderer of the peer you want to take a screenshot of is called remotePeerSurfaceViewRenderer, also I will asume that the button that you will use to take a screenshot is called btnScreenshot
So all what you need to do is as "Webo80" said in the answer above use the FrameListener, the issue is the FrameListener implementation of the webrtc takes only the first frame available once the Listener is attached to the SurfaceViewRenderer, so my approach to do that is by attaching the webrtc implementation of the FrameListsner at the second I need to take a screenshot and remove it once it is taken:
btnScreenshot.setOnClickListener((view)-> {
remotePeerSurfaceViewRenderer.addFrameListsner(new EglRenderer.FrameListener() {
#Override
public void onFrame(Bitmap bitmap) {
runOnUiThread(() -> {
/*
do what ever you want with the bitmap for example
imgView.setImageBitmap(bitmap);
*/
localVideoView.removeFrameListener(this);
});
}
}, 1);
})
Important note:
1. Please don't forget to runOnUiThread as Iam doing
2. Please don't forget to remove the listener inside the button onClick() method
I have tried this solution and it is working more than fine, if you want to make your custom solution you have to completely implement the interface "EglRenderer.FrameListener"
I am sorry to say due to unavailability of canvas and other facilities in Android It's not possible to capture screenshot programatically using WebRTC. One can dodge this situation by animating the app's UI and capturing the screenshot manually , store it at configured location and exchange it with other party.
How do I make my Text-To-Speech stop speaking? Right now, my TTS will start speaking when I launch my application, but I'm trying to make it stop speaking when a button on my Main Activity is pressed.
I have tried creating an onStop() method and using .stop, but to no avail.
May I please get some help on this issue?
You could do something along the lines of this ...
stopSpeakingButton.setOnClickListener(new
View.OnClickListener() {
String toSpeak = " ";
textToSpeech.speak(
toSpeaks,TextToSpeech.QUEUE_FLUSH,null);
});
As you gave us no code this a concept , not the most beautiful solution but will work if you adjust for your use case, the idea is to make it read string with onny a space in it!
Hi I'm developing a game by using andengine.I have a player in my game created with TiledSprite.Also there box2d physic engine.Here is the porblem: Player is moving ahead.But a while later there is a wall on his top and if he wanna continue to go ahead, he has to incline.Incline method just make "player.setCurrentTileIndex(12);". So player image is getting small(incline position).Till here everything is right.But playerBody isn't getting small.That's why he still can't pass the wall by inclining.How can I solve it?
You can understand the problem with photos better:
In this picture, he can't go in there:
http://t1310.hizliresim.com/1g/j/tmpyd.png
In this picture, he can go in there but he can't:
http://j1310.hizliresim.com/1g/j/tmpz2.png
I searched this stutation and found this: destroy the fixture and create new one. But I need this solution with code examples. I couldn't get it well.
You have to create new body for it everytime.
I have created a soundboard and am having trouble getting just one sound to play at a time. If another button is pressed I want the current button to stop playing and the new button to begin. I also want sounds to stop when pressing the next or back button.
Is there any code that can help me out with this?
Here's some information for you that can help you solve your problem:
http://developer.android.com/reference/android/media/SoundPool.html
http://www.androidsnippets.com/playing-sound-fx-for-a-game
But like Falmarri pointed out, we're here to help on code and correct in need, not to write an app for you :)
The Android docs do not tell you how to build something, they only tell you what the parts do. Kinda like throwing parts at someone with detailed information of the parts, then expecting them to build an engine. The real world doesn't work that way!!
Here is what you need Paul. I use this code a lot:
private static SoundManager SM;//Field variable to hold sound manager.
SM = new SoundManager(); //Create sound manager
SM.initSounds(getBaseContext());
SM.addSound(1, R.raw.snd_loop_1);//Add sounds. Sounds go in /res/raw
SM.addSound(2, R.raw.snd_loop_2);
SM.addSound(3, R.raw.snd_ok_1);
Then you can call the sounds on demand with SM.playSound(1);
If you need a permanent running background loop, you can call the same sound with SM.playLoopedSound(2);
I hope it helps!
By default the mediacontroller for video view appears only for 3 sec. I want it to be there untill the song is playing. I know I have to use this peice of code: -
mediacontrollername.show(0);
But apparently it doesn't seems to be doing its job correctly
What should I do for this?
Just in case anyone searched for this issue and still needs a solution, have a look at this: MediaController 3 Second Issue