openVideoBubble method
void
openVideoBubble(
- String path, {
- int startTimeInMilliseconds = 0,
- ControlsType controlsType = ControlsType.STANDARD,
- dynamic onEndServiceTask,
Start Video Bubble service and show the bubble
path
specifies the uri of the file
startTimeInMilliseconds
specify where to start watching the video in milliseconds
controlsType
type of (ui) controls to show on the mini video player (all type avaiable in the enum ControlsType)
onEndServiceTask
callback to call after end of the service. Useful for setting a new time on the main media player
Implementation
void openVideoBubble(String path,
{int startTimeInMilliseconds = 0,
ControlsType controlsType = ControlsType.STANDARD,
onEndServiceTask}) async {
// To call from native android after service close.
_platform.setMethodCallHandler((MethodCall call) async {
print('_handleCloseService method called');
switch (call.method) {
case "getCurrentTime":
print('From Native====');
print(call.arguments.toString());
sendCurrentTimeToCallback(
onEndServiceTask,
call.arguments["isCurrentTimeDirty"].toLowerCase() == "true",
int.parse(call.arguments["currentTime"]));
}
});
bool _seekAtStart = startTimeInMilliseconds == 0 ? true : false;
_platform.invokeMethod('openVideoBubble', [
path,
_seekAtStart,
startTimeInMilliseconds,
controlsType
.toString()
.substring(controlsType.toString().lastIndexOf(".") + 1)
]);
///Creates [_timerVideo] to check periodically if
///bubble [_isVideoOpen] if Service is bounded, [true] if bounded,
///[false] otherwise
_timerVideo = Timer.periodic(Duration(seconds: 1), (timer) async {
_isVideoOpen = await _platform.invokeMethod('isVideoBubbleOpen') ?? false;
if (!_isVideoOpen) {
_timerVideo?.cancel();
}
});
}