Audio and video development technology Singleton mode and audio and video development example Mode

Source: Internet
Author: User

Audio and video development technology Singleton mode and audio and video development example Mode
In the instant messaging project, xiaobian uses the SDK audio and video solution provided by BRAChat, however, the following describes whether the BRAChatCoreSDK object can use the singleton mode and does not want to create a new instance for every region where the BR_ChatCoreSDK object needs to be used:

I. Definition and call
The BR_ChatCoreSDK object can use the singleton mode. You can add the following code to the BR_ChatCoreSDK class to provide the singleton object (for reference only, or other definition methods)

  1. Private static AnyChatCoreSDK anychat;

  2. Public static AnyChatCoreSDK getAnyChatInstance ()
  3. {
  4. If (anychat = null)
  5. Anychat = new AnyChatCoreSDK ();
  6. Return anychat;
  7. }
To copy the code, you only need to call BR_ChatCoreSDK.getBR_ChatInstance () to obtain the unique BR_ChatCoreSDK object.


II. Application scenarios
We recommend that you use the singleton mode when you need to implement a unified class to receive callback messages:
Connect to the server, log on to the server, enter the room, and receive callback messages in the service. You can play audio and video in the activity without receiving callback messages.

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.