setPlayerDataSource method

dynamic setPlayerDataSource(
  1. DataSource dataSource,
  2. Player player,
  3. dynamic seekTo
)

Implementation

setPlayerDataSource(DataSource dataSource, Player player, seekTo) {
  duration.value = Duration.zero;
  if (dataSource.type == DataSourceType.asset) {
    player.open(
      Media.asset(dataSource.source!),
      autoStart: _autoplay,
    );
  } else if (dataSource.type == DataSourceType.network) {
    print(dataSource.source!);
    player.open(
      Media.network(
        dataSource.source!,
        timeout: Duration(seconds: 10),
        //startTime: seekTo
      ),
      autoStart: _autoplay,
    );
  } else {
    player.open(
      Media.file(
        dataSource.file!,
        //startTime: seekTo
      ),
      autoStart: _autoplay,
    );
  }
  if (seekTo != Duration.zero) {
    this.seekTo(seekTo);
  }
  return player;
}