Recently, many customers have reported that some codes of the videoactivity video of the standard Android demo have been transplanted to their own projects and the local video may not be displayed on a black screen or remote video, here we will summarize and describe these problems and provide solutions.
1. Black screen and no display of local videos
Possible cause: No audio/video parameters are set and the Java Collection mode is not used.
Solution: port the applyvideoconfig function in the hallactivity class in the standard demo to the project and call it after initializing the SDK, as shown below
// Initialize the SDK
Anychat. initsdk (Android. OS. Build. version. sdk_int, 0 );
// Set audio and video Parameters
Applyvideoconfig ();
Copy code
(Note: parameters must be set after initialization)
2. The local video can be displayed. The remote video is black or not displayed.
Possible cause: the remote video is not bound to surfaceview.
Solution: Call the bound code before requesting remote video operations, as shown in the following figure.
// If the video is displayed in Java, you need to set the callback of the surface.
If (anychatcoresdk. getsdkoptionint (anychatdefine. brac_so_videoshow_driverctrl) = anychatdefine. videoshow_driver_java ){
Int Index = anychat. mvideohelper. bindvideo (otherview. getholder ());
Anychat. mvideohelper. setvideouser (index, userid );
}
// Request a remote video
Anychat. usercameracontrol (userid, 1 );
Anychat. userspeakcontrol (userid, 1 );
Copy code
(Note: This code must be called if multiple remote videos are requested. For example, in onanychatonlineusermessage and onanychatuseratroommessage, you must call the above Code to enable remote audio and video operations)