[Video Call]Cannot recall the Video Chat - android

I create a CallActivity implement Video Call webrtc. I use quickblox sdk version 2.2.2. The Video Call work fine. But when i ended a Video Call and finish() CallActivity, then i restart CallActivity again, the Video Call not work any more, i can start a new Video Call, but my partner can not receive this Call. I must force stop my app by app manager, Video Call work fine again. Maybe the video call session has problem!
How to recall when restart CallActivity. My destroy() method on CallActivity.
protected void onDestroy() {
super.onDestroy();
handler.removeCallbacks(sendVideoCall);
if (QBChatService.isInitialized()) {
try {
if (QBRTCClient.isInitiated()) {
endCall(getCurrentSession().getUserInfo());
//QBRTCClient.getInstance().getSessions().clear();
QBRTCClient.getInstance().removeCallback(this);
QBRTCClient.getInstance().close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
currentSession = null;
}

We recommend you to update your SDK version to the latest one (2.2.6) as it has most video call issues fixed.
You can download it and chtck the framework changelog here: http://quickblox.com/developers/Android#Download_Android_SDK

Related

How can I ask Android MediaPlayer not to play after onPrepared?

I am working on an Android application which does lots of concurrencies and RxJava treading in the background and it is possible to not want to play a music which is in the async preparation phase for some reason:
player.prepareAsync()
and
override fun onPrepared(mp: MediaPlayer?) {
isPreparing = false
if (playAfterPreparing) {
//start playback
mp?.start()
} else {
// don't play and keep it prepare for later!!!
}
updateNotification()
}
but the problem is after preparation you should play(!) because:
Media Player called in state 0, error (-38,0)
I even tried to start and pause one after another in preparation:
override fun onPrepared(mp: MediaPlayer?) {
Timber.i("onPrepared")
Timber.i("playAfterPreparing: $playAfterPreparing")
isPreparing = false
//start playback
mp?.start()
if (!playAfterPreparing) {
mp?.pause()
}
updateNotification()
}
but it didn't work cause it rendered to the same issue.
I also know how MediaPlayer state machine is working, but don't see anything in this situation in documents:
https://developer.android.com/reference/android/media/MediaPlayer.html
any solution for such a situation?
Thanks to #VladyslavMatviienko comments, I suspected that I am doing something wrong somewhere else and he was correct. According to Android MediaPlayer document:
It is possible to stay in Prepared state, but it is not possible to call any method namely pause() and that was my fault. In Prepared state You can only call start(), seekTo() or stop().
Hope this answer comes handy for those who might face this issue later.

Using IBM mobile first Android sdk in Background service when the app is killed.

We are trying to make a sync adapter service in Android which will run in the background when the app is killed.
This service will fetch some data from JsonStore and will sync up with the server.
Code:
try {
URI adapterPath = new URI("/dummy/adapter");
WLResourceRequest request = new WLResourceRequest(adapterPath,WLResourceRequest.POST);
request.send(new AdapterListener(new CallbackAdapter() {
#Override
public void onFetch(String response) {
// TODO Auto-generated method stub
}
#Override
public void onError(String error) {
// TODO Auto-generated method stub
}
}));
} catch (URISyntaxException e) {
e.printStackTrace();
}
Problems:
When we try to run service in a different process, we get an error at line ( WLResourceRequest request = new WLResourceRequest(adapterPath,WLResourceRequest.POST);) that WL.getInstance should be called after WL.createInstance but we can not create WL instance in service because it needs an instance of ACTIVITY.
When we try to run service in the same process, in which the app is currently running, everything works fine untile app is running but if we kill the app same things happen which are happening at point 1.
Questions:
Is there a way we can create WL instance in service.
Is there a way we can let WL instance initialized forever, even though user kills the app.
Is there a way we can let our app run forever with WL instance initialized forever.
I got it working, all you need to add
WL.App.setKeepAliveInBackground(true);
into the js file and WL instance will work with sync adapters and services in Android.
Running the MobileFirst Android SDK in an Android Service is currently not supported. There is an open feature request for this ability, so please feel free to add your vote if you can want to make this happen. Search here: https://mobilefirstplatform.ibmcloud.com/help/

Android Brightcove onVideo does not get called sometimes and hence video does not play

I have integrated Brightcove android-sdk-4.2.7 and trying to play video using videoID.
Here is the code snippet :
Catalog catalog = new Catalog(<**MEDIA_READ_TOKEN**>);
catalog.findVideoByID(videoId, new VideoListener() {
#Override
public void onError(String error) {
Log.e(TAG, "onError : " + error);
}
#Override
public void onVideo(Video video) {
Log.i(TAG, "onVideo called" );
brightcoveVideoView.add(video);
brightcoveVideoView.start();
}
});
When I launch video_player_activity from other activity for the first time video plays perfectly fine, but when I go back to second activity and again try to play the same/other video, It does not play. onVideo does not get called. Sometimes it gets called after a long time.
Following are some more details :
activity is getting destroyed properly when I go back
onError is not getting called
video id is getting set properly
Tried emitter events and READY_TO_PLAY event occurs but DID_PLAY does not
Android version I tested on is 4.4.x
What might be the possible issues? Any help/pointer around this will be really appreciated.
Thanks!
Repeated calls to findVideoByID(), should work fine. For each one, you should see a request in the logcat, something like:
D/HttpService(27297): issuing GET request: http://api.brightcove.com/services/library?command=find_video_by_id&video_id=3603631382001...
and a response, something like:
D/HttpService(27297): response: {"id":36036...
If that is not the case, please file a bug with Brightcove Support. If that is working, there isn't enough information here to debug further. You could try to compare what you are doing with the public sample apps available on Github:
https://github.com/BrightcoveOS/android-player-samples
These apps don't have multiple activities like your scenario, but they do handle the app going into the background and then being brought back to the foreground. Extending the BrightcovePlayer or BrightcovePlayerFragment enables the lifecycle handling. If you don't extend one of those classes, you have to write your own lifecycle handling, as if you were using the Android VideoView. For example, calling pause() in onPause() and calling stopPlayback() in onStop().

Looking for an example of the new Android API setMediaButtonReceiver

Currently I am using
mAudioManager.registerMediaButtonEventReceiver(mRemoteControlResponder);
but this is now deprecated in 5.0 and replaced by setMediaButtonReceiver. There are 5 links in Google all pointing to developer.android.com.
Has anyone used this yet? If so can you provide an example?
Check this page: http://grepcode.com/file/repo1.maven.org/maven2/org.robolectric/android-all/5.0.0_r2-robolectric-0/android/media/session/MediaSession.java It is a rather large example of the complete flow.Here one of the most relevant parts
Set a pending intent for your media button receiver to allow restarting playback after the session has been stopped. If your app is started in this way an android.content.Intent.ACTION_MEDIA_BUTTON intent will be sent via the pending intent.
Parameters: nullmbr The android.app.PendingIntent to send the media button event to.
public void More ...setMediaButtonReceiver(#Nullable PendingIntent mbr) {
try {
mBinder.setMediaButtonReceiver(mbr);
} catch (RemoteException e) {
Log.wtf(TAG, "Failure in setMediaButtonReceiver.", e);
}
}

Stagefright media delay in 2.2 after setting data source?

My first post here. This website has been very useful for learning Android programming, thanks to everyone.
I have a simple app that loads an MP3 stream and plays it. It works fine on 1.6 and 2.1 but on 2.2 it doesn't quite work right. It seems my service is having a problem starting, it's giving my an ANR and the dialog where I have to tap "Wait", and then finally the service starts. Why is the service taking a long time to start up?
Here's my simple code that sets the source and plays the audio:
public class MyActivityService extends Service {
MediaPlayer player = new MediaPlayer();
#Override
public IBinder onBind(Intent intent) {
return null;
}
#Override
public void onCreate() {
super.onCreate();
try {
player.setDataSource("URL OF MUSIC FILE");
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
player.prepare();
player.setVolume(1, 1);
player.setLooping(true);
player.start();
Toast.makeText(getApplicationContext(), "Audio Service Started.", Toast.LENGTH_SHORT).show();}
ADDENDUM:
Turns out it wasn't my service not starting, it's the audio that's not starting quickly enough in 2.2...
I got rid of the ANRs when my service started and stopped by putting the onCreate() and onDestroy() methods of my service in their own threads, which is probably how it should have been from the beginning? Sorry, just learning.
But the delay that's the real problem remains, to clarify --
For example, my code, as it is right now, works fine and dandy and just how I want it to in 2.1 AND 2.2 when I set the data source to an MP3 file like this: http://dl.dropbox.com/u/6916184/TestSongStream.mp3
BUT when I set the data source to an audio stream location like this: http://d.liveatc.net/kjfk_twr or this: http://relay.radioreference.com:80/192236577 it works correctly ONLY in 2.1.
In 2.2 the sound does start playing eventually, but it takes "StagefrightPlayer" about 25 seconds or so after setting the data source until the audio starts as shown here:
07-31 02:54:30.176: INFO/StagefrightPlayer(34): setDataSource('http://relay.radioreference.com:80/192236577')
07-31 02:54:55.228: INFO/AwesomePlayer(34): calling prefetcher->prepare()
07-31 02:54:56.231: INFO/Prefetcher(34): [0x2cc28] cache below low water mark, filling cache.
07-31 02:54:56.337: INFO/AwesomePlayer(34): prefetcher is done preparing
07-31 02:54:56.347: DEBUG/AudioSink(34): bufferCount (4) is too small and increased to 12
07-31 02:54:57.337: ERROR/AwesomePlayer(34): Not sending buffering status because duration is unknown.
It also takes the same amount of time, about 25 seconds, to stop the media player after player.stop() is called in the onDestroy() method of my service, and the onDestroy() method continues on to Toast a message and cancel a notification.
Is that just the way it is with 2.2? If so, I can work around the delays, that's not a problem. Or more likely is it something I am doing wrong? But it works exactly as I want in 1.6 and 2.1!
Would posting more code help?
My code is very simple. There are no audio controls or anything like that. Simply a start audio button and stop audio button that start and stop a service that plays an audio stream.
Thank you for any help!
Do not call prepare() from the main application thread, particularly for a stream, because that may take much longer than you're allowed before an ANR. Use prepareAsync() instead. I have no idea if that is the root of your particular problem, but it would certainly be one cause of an ANR in your current implementation.

Categories

Resources