• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Build a Flutter Live Streaming App in 10 Minutes

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Ready to add live streaming to your next mobile app? In this quick tutorial, I’ll show you how to integrate the

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

, set up a fully-functional UI, and get your very own broadcast feature running—all in just 10 minutes. Whether you’re looking to enrich your current application or prototype a brand-new platform, this streamlined guide may help you.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Step 1. Activate the service


Before using the Audio and Video Services, you need to go to the Console and activate the service for your application. For detailed steps, refer to

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

.

Step 2. Import the TUILiveKit component


From the root directory of the project, install the component

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

plug-in by executing the following command from the command line.


flutter pub add tencent_live_uikit
Step 3. Complete the project configuration

  1. If you need to compile and run on the Android platform, because we use Java's reflection features inside the SDK, you need to add some classes in the SDK to the non-confusion list.

First, you need to configure and enable the obfuscation rule in your project's android/app/build.gradle file:


android {
......
buildTypes {
release {
......
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

Create a proguard-rules.pro file in the android/app directory of the project, and add the following code in the proguard-rules.pro file:


keep class com.tencent.** { *; }
  1. Configure to enable Multidex support in the android/app/build.gradle file of your project.

android {
......
defaultConfig {
......
multiDexEnabled true
}
}
Step 4. Set up navigatorObserver and localizationsDelegates


In the Flutter application framework, add TUICallKit.navigatorObserver to navigatorObservers, and add LiveKitLocalizations.localizationsDelegates to localizationsDelegates. For example, using the MaterialApp framework, the code is as follows:


import 'package:tencent_live_uikit/tencent_live_uikit.dart';

......

class XXX extends StatelessWidget {
const XXX({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorObservers: [TUILiveKitNavigatorObserver.instance],
localizationsDelegates: [...LiveKitLocalizations.localizationsDelegates],
......
);
}
}
Step 5. log in to TUILiveKit componet


To log in to the TUICallKit component, add the following code to your project to call the relevant APIs in TUICore. This step is very important, as the user can use the component features properly only after successfully logging in. Carefully check that the relevant parameters are correctly configured:


import 'package:tencent_cloud_uikit_core/tencent_cloud_uikit_core.dart';
......

login() async {
await TUILogin.instance.login(
1400000001, // Please replace with the SDKAppID obtained from step one
"denny", // Replace it with your UserID
"xxxxxxxxxxx", // Calculate a UserSig in the console and enter it here
TUICallback(
onError: (code, message) {
print("TUILogin login fail, {code:$code, message:$message}");
},
onSuccess: () async {
print("TUILogin login success");
},
),
);
}

Parameter description: The key parameters used by the login function are as detailed below:

SDKAppID: Obtained in the last step in

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

and not detailed here.

UserID: The ID of the current user, which is a string that can contain only letters (a–z and A–Z), digits (0–9), hyphens (-), or underscores (_).

UserSig: The authentication credential used by Tencent Cloud to verify whether the current user is allowed to use the TRTC service. You can get it by using the SDKSecretKey to encrypt the information such as SDKAppID and UserID. You can generate a temporary UserSig on the

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

** page in the console.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



For more information, see

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

.

Step 6. Enter the live preview screen


Note: Make sure you've correctly followed

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

to complete the login. Only after you log in to TUILogin.login can you enter the live preview screen normally.

In the code section where you start live streaming (executed with a click event), perform the following operations to launch the host's live streaming page:


import 'package:tencent_live_uikit/tencent_live_uikit.dart';
......

Navigator.push(context, MaterialPageRoute(
builder: (context) {
return TUILiveRoomAnchorWidget(
roomId: LiveIdentityGenerator.instance.generateId(AppStore.userId, RoomType.live));
},
));


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу