Skip to content

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

Description

@shMolaee

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'.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions