Step2. Start the Shoplive Player

    Step2. Start the Shoplive Player


    Article summary

    Play a Live Stream

    Initialize the Shoplive Flutter SDK using the prepared Access Key and Campaign Key, then start the player.

    import 'package:shoplive_player/shoplive_common.dart';
    final _shopLiveCommon = ShopLiveCommon();
    _shopLiveCommon.setAccessKey(accessKey: "{AccessKey}");

    Play a Broadcast

    You can play a live broadcast using a Campaign (Broadcast) Key.

    import 'package:shoplive_player/shoplive_player.dart';
    final _player = ShopLivePlayer();
    _player.play(data: ShopLivePlayerData(campaignKey: "CampaignKey"));

    ShopLivePlayerData

    Property name

    Type

    Description

    campaignKey

    String

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

    keepWindowStateOnPlayExecuted

    bool

    Whether to start playback while preserving the current player mode (PIP or fullscreen). Default is false.

    • true: Keeps the current player mode.

    • false: Starts playback in fullscreen mode.

    referrer

    String?

    Parameter used to track entry source statistics

    ShopLiveCommonUser

    Property name

    Type

    Description

    userId

    String

    Unique user ID used by the service (required)

    userName

    String?

    Name displayed in chat and player UI

    age

    int?

    User age

    gender

    ShopLiveCommonUserGender?

    User gender (MALE, FEMALE, NEUTRAL)

    userScore

    int?

    User level or grade

    custom

    Map<String, dynamic>?

    Custom user-defined data


    Stop the Live Stream

    Close the live detail screen by calling close()

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