initialize static method
Future<void>
initialize(
{ - bool useFlutterNativeView = false,
})
Implementation
static Future<void> initialize({
bool useFlutterNativeView = false,
}) async {
if (useFlutterNativeView && Platform.isWindows) {
/// Windows specific [NativeVideo].
WidgetsFlutterBinding.ensureInitialized();
await FlutterNativeView.ensureInitialized();
}
FFI.videoFrameCallback = (int playerId, Uint8List videoFrame) {
if (videoStreamControllers[playerId] != null &&
FFI.players[playerId] != null) {
if (!videoStreamControllers[playerId]!.isClosed) {
videoStreamControllers[playerId]!.add(
VideoFrame(
playerId: playerId,
videoWidth: FFI.players[playerId]!.videoDimensions.width,
videoHeight: FFI.players[playerId]!.videoDimensions.height,
byteArray: videoFrame,
),
);
}
}
};
if (Platform.isWindows) {
final libraryPath = path.join(
path.dirname(Platform.resolvedExecutable),
'dart_vlc_plugin.dll',
);
FFI.DartVLC.initialize(libraryPath);
} else if (Platform.isLinux) {
final libraryPath = path.join(
path.dirname(Platform.resolvedExecutable),
'lib',
'libdart_vlc_plugin.so',
);
FFI.DartVLC.initialize(libraryPath);
} else if (Platform.isMacOS) {
final libraryPath = path.join(
path.dirname(path.dirname(Platform.resolvedExecutable)),
'Frameworks',
'dart_vlc.framework',
'dart_vlc',
);
FFI.DartVLC.initialize(libraryPath);
} else if (Platform.isIOS) {
final libraryPath = path.join(
path.dirname(Platform.resolvedExecutable),
'Frameworks',
'dart_vlc.framework',
'dart_vlc',
);
FFI.DartVLC.initialize(libraryPath);
}
}