AgoraIO-Extensions / Agora-Flutter-SDK

Flutter plugin of Agora RTC SDK for Android/iOS/macOS/Windows
https://pub.dev/packages/agora_rtc_engine
MIT License
743 stars 385 forks source link

How to use VirtualBackground when Live Streaming #500

Closed PongPloy2016 closed 11 months ago

PongPloy2016 commented 2 years ago

How to use set VirtualBackground when Live Streaming

I use lean link :

and i custom in link becouse i want streaming to rtmp + key other

@override Future enableVirtualBackground( bool enabled, VirtualBackgroundSource backgroundSource) { return _invokeMethod('enableVirtualBackground', { 'enabled': enabled, 'backgroundSource': backgroundSource.toJson(), }); }

i tryeing set method then Call this method after enableVideo

VirtualBackgroundSource backgroundSource = VirtualBackgroundSource( color: Color.fromRGBO(38, 38, 38, 0.4), source: "/data/user/0/com.hollysoft.ar_live_ais/cache/file.jpg", backgroundSourceType: VirtualBackgroundSourceType.Img);

await _engine.enableVirtualBackground(true, backgroundSource);

  Future<void> _initAgora() async {
    _engine = await RtcEngine.createWithConfig(RtcEngineConfig(appId));
    _client = await AgoraRtmClient.createInstance(appId);
    //AssetSetup
    await _engine.enableVideo();
    VirtualBackgroundSource backgroundSource = VirtualBackgroundSource(
        color: Color.fromRGBO(38, 38, 38, 0.4),
        source: "/data/user/0/com.hollysoft.ar_live_ais/cache/file.jpg",
        backgroundSourceType: VirtualBackgroundSourceType.Img);

    await _engine.enableVirtualBackground(true, backgroundSource);

    await _engine.startPreview();
    await _engine.muteLocalAudioStream(true);
    await _engine.muteLocalVideoStream(true);
    await _engine.setChannelProfile(ChannelProfile.LiveBroadcasting);
    await _engine.setClientRole(ClientRole.Broadcaster);

    _joinChannel();
  }

  _joinChannel() async {
    if (defaultTargetPlatform == TargetPlatform.android) {
      await [Permission.microphone, Permission.camera].request();
    }
    await _engine.joinChannel(config.token, config.channelId, null, config.uid);
  }
Screen Shot 2564-11-23 at 01 47 57

and run bulid and the result turned out to be change color black background not show file set , no color, no background, and wallpaper doesn't show. but i not understant you write detail because you hot have example for VirtualBackground in Live Streaming
i not understant String? source How to use please example code Any advice please?

ask more

and more question if can try to get gif files and text, text or fonts can be dragged and drag files freely and if not, is there any one that can try to accept withCan Agora?

Please fully example for VirtualBackground when Live Streaming

Thank you

LichKing-2234 commented 2 years ago

Is it working without VirtualBackgroundSource?

PongPloy2016 commented 2 years ago

ok bro. thank you

littleGnAl commented 12 months ago

If you still face issues, please try upgrading to the new version to see if it works for you.

github-actions[bot] commented 11 months ago

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. If you find this problem please file a new issue with the same description, what happens, logs and the output. All system setups can be slightly different so it's always better to open new issues and reference the related ones. Thanks for your contribution.

github-actions[bot] commented 11 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please raise a new issue.