Player constructor
Player({})
Player
A Player object can be used for media playback. A unique id must be passed for creating & controlling a Player instance.
When using on Flutter Linux, startLoop
must be passed as false
.
Player player = Player(id: 0);
player.open([
Media(uri: 'https://www.example.com/music.mp3'),
Media(uri: 'file://C:/documents/video.mp4'),
]);
player.play();
Implementation
Player({
required this.id,
bool showWindow = false,
String windowTitle = 'libwinmedia',
bool startLoop = true,
}) {
nativeControls = PlayerNativeControls(id: id);
players[id] = this;
LWM.bindings.PlayerCreate(
id,
showWindow,
windowTitle.toNativeUtf8(),
);
if (Platform.isLinux) {
if (startLoop) {
LWM.dynamicLibrary
.lookupFunction<Void Function(), void Function()>('PlayerRun')();
}
}
LWM.bindings.PlayerSetRateEventHandler(
id,
Pointer.fromFunction(doubleC),
);
LWM.bindings.PlayerSetVolumeEventHandler(
id,
Pointer.fromFunction(doubleC),
);
LWM.bindings.PlayerSetPositionEventHandler(
id,
Pointer.fromFunction(intC),
);
LWM.bindings.PlayerSetDurationEventHandler(
id,
Pointer.fromFunction(intC),
);
LWM.bindings.PlayerSetIndexEventHandler(
id,
Pointer.fromFunction(intC),
);
LWM.bindings.PlayerSetIsPlayingEventHandler(
id,
Pointer.fromFunction(intC),
);
LWM.bindings.PlayerSetIsBufferingEventHandler(
id,
Pointer.fromFunction(intC),
);
LWM.bindings.PlayerSetIsCompletedEventHandler(
id,
Pointer.fromFunction(intC),
);
LWM.bindings.PlayerSetDownloadProgressEventHandler(
id,
Pointer.fromFunction(doubleC),
);
LWM.bindings.PlayerSetErrorEventHandler(
id,
Pointer.fromFunction(errorC),
);
}