create static method
PlayerController
create({
- int? id,
- required PlayerMedia media,
- bool? autoPlay,
- bool? once,
- bool? loop,
create instance adapted on platform
var media = PlayerMedia.asset(assets/file.mp3);
Player.create(id: 1, media: media, autoPlay: false, once: false)
..init();
player.play();
Implementation
static PlayerController create({
int? id,
required PlayerMedia media,
bool? autoPlay,
bool? once,
bool? loop,
}) {
// select player depending on platform
final PlayerAdaptivePackage? playerFactory =
platforms[PlatformEnv.environment];
if (playerFactory == null) {
throw UnsupportedError(
'[KPlayer] Platform ${PlatformEnv.environment} is not supported.',
);
}
return playerFactory.factory(
id: id,
media: media,
autoPlay: autoPlay,
once: once,
loop: loop,
);
}