feat: added 'Add Video' feature

This commit is contained in:
jideguru
2021-06-06 21:09:09 +01:00
parent 066b2019f2
commit 7b809401ec
6 changed files with 100 additions and 25 deletions

View File

@@ -198,6 +198,23 @@ class JavascriptExecutorBase {
);
}
insertVideo(String url,
{int? width, int? height, bool fromDevice = true}) async {
bool? local;
local = fromDevice ? true : null;
if (width == null) width = 300;
if (height == null) height = 220;
// check if link is yt link
if (url.contains('youtu')) {
// Get Video id from link.
String youtubeId = url.split(r'?v=')[1];
url = 'https://www.youtube.com/embed/$youtubeId';
}
await executeJavascript(
"insertVideo('$url', '$width', '$height', $local);",
);
}
insertCheckbox(String text) async {
await executeJavascript("insertCheckbox('$text');");
}