Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The getter 'duration' isn't defined for the class 'MediaElement'. #88

Open
shMolaee opened this issue Oct 31, 2023 · 1 comment
Open

Comments

@shMolaee
Copy link

I wrote this method to get media time in Flutter, everything is fine on the web, but it gives me this error on other platforms.

code:
Future<double> getWebDuration(Uint8List bytes, MediaType mediaType) async { final blob = Blob([bytes]); final url = Url.createObjectUrlFromBlob(blob); final audio = (mediaType == MediaType.video ? VideoElement() : AudioElement()) ..src = url ..autoplay = false; document.body?.append(audio); final duration = await Future(() { final completer = Completer<double>(); audio.onLoadedData.listen((event) { late final duration; if (isWeb) { duration = audio.duration; } Url.revokeObjectUrl(url); audio.remove(); completer.complete(duration.toDouble()); }); return completer.future; }); return duration; }

lib/utils/file/media_duration.dart(25,26): error G4127D1E8: The getter 'duration' isn't defined for the class 'MediaElement'.

@Megatronicus
Copy link

Is that similar to this
#86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants