Live api

    Live api


    Article summary

    Installing Live

    https://pub.dev/packages/shoplive_player/install

    Depend on it

    Run this command:

    With Flutter:

     $ flutter pub add shoplive_player

    This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

    dependencies:
      shoplive_player: ^1.6.5

    Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

    Import it

    Now in your Dart code, you can use:

    import 'package:shoplive_player/shoplive_player.dart';


    Go Live

    void play({required ShopLivePlayerData data})to play the live detail screen.

    ShopLivePlayerData

    Property name

    Type

    Description

    campaignKey

    String

    Campaign (broadcast) key of the video to be played (required)

    keepWindowStateOnPlayExecuted

    Boolean

    Whether to start playback while maintaining the running mode (pip, fullscreen) of the player being played. Default (false)

    • true: Keeps the running mode of the player being played.

    • false: Runs in fullscreen.

    referrer

    String?

    Parameters that allow you to measure entry path statistics

    late final _shopLivePlayerPlugin = ShopLivePlayer();
    _shopLivePlayerPlugin.play(data: data);


    Ending a Live

    void close()to exit the live details screen.

    late final _shopLivePlayerPlugin = ShopLivePlayer();
    _shopLivePlayerPlugin.close();


    Run a live preview

    void showPreview({required ShopLivePlayerPreviewData data})to run a live preview.

    ShopLivePlayerPreviewData

    Property name

    Type

    Description

    campaignKey

    String

    Campaign (broadcast) key of the video to be played (required)

    useCloseButton

    Boolean

    Activate the Close button. Default (false)

    referrer

    String?

    Parameters that allow you to measure entry path statistics

    late final _shopLivePlayerPlugin = ShopLivePlayer();
    _shopLivePlayerPlugin.showPreview(data: data);


    Share Set your address

    void setShareScheme({required String shareSchemeUrl})You can set the share address via

    late final _shopLivePlayerPlugin = ShopLivePlayer();
    _shopLivePlayerPlugin.setShareScheme(shareSchemeUrl: "https://shoplive.cloud/");


    Switching PIP

    void startPictureInPicture() to switch from full-screen mode to picture-in-picture mode.

    late final _shopLivePlayerPlugin = ShopLivePlayer();
    _shopLivePlayerPlugin.startPictureInPicture();


    Switch to full screen

    void stopPictureInPicture()via the Picture-in-picture mode to full-screen mode.

    late final _shopLivePlayerPlugin = ShopLivePlayer();
    _shopLivePlayerPlugin.stopPictureInPicture();


    Start muting

    void setMuteWhenPlayStart({required bool isMute})You can start muting it via.

    late final _shopLivePlayerPlugin = ShopLivePlayer();
    _shopLivePlayerPlugin.setMuteWhenPlayStart(isMute: false);


    Product and banner information delivery function

    Stream<ShopLiveHandleNavigation> handleNavigationWhen you select a product, banner, etc., in Live, the selected product or banner information will be delivered.

    late final _shopLivePlayerPlugin = ShopLivePlayer();
    _shopLivePlayerPlugin.handleNavigation.listen((data) {
      _showToast("handleNavigation : ${data.url}");
    });


    Coupon information delivery function

    Stream<ShopLiveHandleDownloadCoupon> handleDownloadCouponWhen you select a coupon in Live, the selected coupon information will be delivered.

    late final _shopLivePlayerPlugin = ShopLivePlayer();
    _shopLivePlayerPlugin.handleDownloadCoupon.listen((data) {
      _showToast("handleDownloadCoupon : ${data.couponId}");
    });


    Broadcast Status Forwarding Function

    Stream<ShopLiveChangeCampaignStatus> changeCampaignStatusCommunicates when the broadcast status has changed in the live broadcast.

    ShopLiveChangeCampaignStatus

    Parameter name

    Type

    Description

    campaignStatus

    String

    campaignStatus: READY, ONAIR, CLOSED

    late final _shopLivePlayerPlugin = ShopLivePlayer();
    _shopLivePlayerPlugin.changeCampaignStatus.listen((data) {
      _showToast("changeCampaignStatus : ${data.campaignStatus}");
    });


    Campaign information delivery function

    Stream<ShopLiveCampaignInfo> campaignInfoYou can check the campaign information in the live.

    ShopLiveCampaignInfo

    Parameter name

    Type

    Description

    campaignInfo

    JSONObject

    campaignInfo

    For example: {'title':'방송 제목'}

    late final _shopLivePlayerPlugin = ShopLivePlayer();
    _shopLivePlayerPlugin.campaignInfo.listen((data) {
      _showToast(
          "campaignInfo : ${const JsonEncoder().convert(data.campaignInfo)}");
    });


    Pop-up Custom Features

    Stream<ShopLiveHandleCustomAction> handleCustomAction Specify the selection event custom in the pop-up as and pass the pop-up information when the pop-up is selected. Passing the pop-up's id, type, , payload.

    ShopLiveHandleCustomAction

    Parameter name

    Type

    Description

    id

    String

    Coupon or Banner ID

    type

    String

    Coupon or banner type

    payload

    String

    User-defined payload

    late final _shopLivePlayerPlugin = ShopLivePlayer();
    _shopLivePlayerPlugin.handleCustomAction.listen((data) {
      _showToast(
          "handleCustomAction : ${data.id}, ${data.type}, ${data.payload}");
    });


    Player status information delivery function

    Stream<ShopLiveChangedPlayerStatus> changedPlayerStatus to receive the status of the live player.

    ShopLiveChangedPlayerStatus

    Parameter name

    Type

    Description

    status

    ShopLivePlayStatus

    Player status (created, destroyed)

    late final _shopLivePlayerPlugin = ShopLivePlayer();
    _shopLivePlayerPlugin.changedPlayerStatus.listen((data) {
      _showToast("changedPlayerStatus: ${data.status}");
    });


    Message callback verification function

    Stream<ShopLiveReceivedCommand> receivedCommand You can check the content of the message you have received.

    ShopLiveReceivedCommand

    Property name

    Type

    Description

    command

    String

    The name of the Command

    data

    Map<String, dynamic>?

    Additional related parameters

    late final _shopLivePlayerPlugin = ShopLivePlayer();
    _shopLivePlayerPlugin.receivedCommand.listen((data) {
      _showToast(
          "receivedCommand : ${data.command}, ${const JsonEncoder().convert(data.data)}");
    });


    Log Function

    Stream<ShopLivePlayerLog> log to receive live logs.

    ShopLivePlayerLog

    Property name

    Type

    Description

    name

    String

    The name of the event.

    feature

    String

    Types click of Event, show, action

    campaignKey

    String?

    Unique Key in Broadcasting

    parameter

    Map<String, dynamic>?

    Additional related parameters

    late final _shopLivePlayerPlugin = ShopLivePlayer();
    _shopLivePlayerPlugin.log.listen((data) {
      _showToast(
          "clickLog : ${data.name}, ${data.feature}, ${data.campaignKey}, ${const JsonEncoder().convert(data.payload)}");
    });