play method

  1. @override
bool play(
  1. String url, {
  2. StreamType? type,
  3. bool? hardWareDecode,
  4. bool? isStreamEncrypted,
})
override

播放。 url:拉流地址 type:流协议,可以写死。不同平台可能使用不同协议。一般安卓和ios用eh5,h5用的eh4 hardWareDecode:是否使用硬件编码,可以写死。没有可以不管 isStreamEncrypted:视频流是否为加密

Implementation

@override
bool play(String url, {StreamType? type, bool? hardWareDecode, bool? isStreamEncrypted}) {
  if (url.isEmpty) {
    return false;
  }
  sdkLog("[player] >> play > $url");
  playTimeMs = DateTime.now().millisecondsSinceEpoch;
  if (showLiveRoomTimeMs > 0) {
    // debugLog("显示直播间到开始拉流:${playTimeMs - showLiveRoomTimeMs}ms, url:$url", tag: "LivePlayerUsedTime");
    showLiveRoomTimeMs = 0;
  }

  if (pullStreamUrl.isEmpty) {
    this.isStreamEncrypted = isStreamEncrypted ?? true;
    _impl.play(url, type: type, hardWareDecode: hardWareDecode, isStreamEncrypted: isStreamEncrypted);
  } else {
    _impl.switchStream(url);
  }
  pullStreamUrl = url;
  return true;
}