part of '../ijkplayer.dart'; /// about channel MethodChannel _globalChannel = MethodChannel("top.kikt/ijkplayer"); Future _createIjk({ List options, }) async { List> _optionList = []; for (var option in options) { _optionList.add(option.toMap()); } int id = await _globalChannel.invokeMethod( "create", { "options": _optionList, }, ); return id; } class _IjkPlugin { MethodChannel get channel => MethodChannel("top.kikt/ijkplayer/$textureId"); /// texture id int textureId; _IjkPlugin(this.textureId); Future dispose() async { await _globalChannel.invokeMethod("dispose", {"id": textureId}); } Future play() async { await channel.invokeMethod("play"); } Future pause() async { await channel.invokeMethod("pause"); } Future stop() async { await channel.invokeMethod("stop"); } Future setNetworkDataSource( {String uri, Map headers = const {}}) async { LogUtils.debug("id = $textureId net uri = $uri ,headers = $headers"); await channel.invokeMethod("setNetworkDataSource", { "uri": uri, "headers": headers, }); } Future setAssetDataSource(String name, String package) async { LogUtils.debug("id = $textureId asset name = $name package = $package"); var params = { "name": name, }; if (package != null) { params["package"] = package; } await channel.invokeMethod("setAssetDataSource", params); } Future setFileDataSource(String path) async { if (!File(path).existsSync()) { return Error.fileNotExists; } await channel.invokeMethod("setFileDataSource", { "path": path, }); LogUtils.debug("id = $textureId file path = $path"); } Future> getInfo() async { try { var map = await channel.invokeMethod("getInfo"); if (map == null) { return null; } else { return map.cast(); } } on Exception { return null; } } Future seekTo(double target) async { await channel.invokeMethod("seekTo", { "target": target, }); } /// Future setVolume(int volume) async { await channel.invokeMethod("setVolume", { "volume": volume, }); } Future screenShot() async { var result = await channel.invokeMethod("screenShot"); if (result == null) { return null; } return result; } }