Porting some code of the standard Demo Video to common problems and solutions in the project

Source: Internet
Author: User

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

  1. // Initialize the SDK
  2. Anychat. initsdk (Android. OS. Build. version. sdk_int, 0 );
  3. // Set audio and video Parameters
  4. 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.

  1. // If the video is displayed in Java, you need to set the callback of the surface.
  2. If (anychatcoresdk. getsdkoptionint (anychatdefine. brac_so_videoshow_driverctrl) = anychatdefine. videoshow_driver_java ){
  3. Int Index = anychat. mvideohelper. bindvideo (otherview. getholder ());
  4. Anychat. mvideohelper. setvideouser (index, userid );
  5. }
  6. // Request a remote video
  7. Anychat. usercameracontrol (userid, 1 );
  8. 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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.