Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Conversation

@mhbdev
Copy link

@mhbdev mhbdev commented Oct 19, 2020

Description

I was trying to make a webcam recorder for flutter web. so I ran into creating html.MediaRecorder and MediaStream to record video and audio both in a file. after recording a simple webm video, something was wrong about the file. Flutter video_player library could not load my video (tested on web platform) and I was getting the error below!

The thing is It's a chrome bug I assume. look it here :)

Error: Unsupported operation: Infinity
    at Object.throw_ [as throw] (http://localhost:37461/dart_sdk.js:4328:11)
    at Number.[dartx.round] (http://localhost:37461/dart_sdk.js:15560:17)
    at video_player_web._VideoPlayer.new.sendInitialized (http://localhost:37461/packages/video_player_web/video_player_web.dart.lib.js:300:259)
    at http://localhost:37461/packages/video_player_web/video_player_web.dart.lib.js:254:16
    at Object._checkAndCall (http://localhost:37461/dart_sdk.js:4538:16)
    at Object.dcall (http://localhost:37461/dart_sdk.js:4543:17)
    at HTMLVideoElement.<anonymous> (http://localhost:37461/dart_sdk.js:105045:21)

Related Issues

No related issue!

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

(This happens because of a chromium bug https://bugs.chromium.org/p/chromium/issues/detail?id=656426)

```Error: Unsupported operation: Infinity
    at Object.throw_ [as throw] (http://localhost:37461/dart_sdk.js:4328:11)
    at Number.[dartx.round] (http://localhost:37461/dart_sdk.js:15560:17)
    at video_player_web._VideoPlayer.new.sendInitialized (http://localhost:37461/packages/video_player_web/video_player_web.dart.lib.js:300:259)
    at http://localhost:37461/packages/video_player_web/video_player_web.dart.lib.js:254:16
    at Object._checkAndCall (http://localhost:37461/dart_sdk.js:4538:16)
    at Object.dcall (http://localhost:37461/dart_sdk.js:4543:17)
    at HTMLVideoElement.<anonymous> (http://localhost:37461/dart_sdk.js:105045:21)
```
[video_player_web] Error: Unsupported operation: Infinity.
Copy link
Author

@mhbdev mhbdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Nothing but a simple if.
I'm editing the file on github editor. sorry about that :(
@rrousselGit
Copy link

👋

Are you maybe trying to do some live-streaming? Looking at the chrome ticket you linked, it was closed as "not a bug" because infinity is when the video has no known duration (typically live-streams)

Maybe this is related to flutter/flutter#30687?

If so, I'm not sure if that's a valid fix for this problem.

In any case, we'll want so tests to avoid future regressions

@alikhaleghi76
Copy link

@mhbdev
Hi, I have same problem. Did you find any solution?

@rafie-tarabay
Copy link

rafie-tarabay commented Jun 23, 2021

here is the solution: blobUrlPlayer(source: widget.URL)

    import 'package:flutter/material.dart';
    import 'dart:html';
    import 'dart:ui' as ui;
    
    class blobUrlPlayer extends StatefulWidget {
      final String source;
    
      blobUrlPlayer({Key key, @required this.source}) : super(key: key);
    
      @override
      _blobUrlPlayerState createState() => _blobUrlPlayerState();
    }
    class _blobUrlPlayerState extends State<blobUrlPlayer> {
      // Widget _iframeWidget;
      final videoElement = VideoElement();
    
      @override
      void initState() {
        super.initState();
        videoElement
        ..src = widget.source
        ..autoplay = true
        ..controls = false
        ..style.border = 'none'
        ..style.height = '100%'
        ..style.width = '100%';
    
        // Allows Safari iOS to play the video inline
        videoElement.setAttribute('playsinline', 'true');
    
        // Set autoplay to false since most browsers won't autoplay a video unless it is muted
        videoElement.setAttribute('autoplay', 'false');
    
        //ignore: undefined_prefixed_name
        ui.platformViewRegistry.registerViewFactory(
            widget.source, (int viewId) => videoElement);
      }
    
      @override
      Widget build(BuildContext context) {
        return HtmlElementView(
          key: UniqueKey(),
          viewType: widget.source,
        );
      }
    }

@stuartmorgan-g
Copy link
Contributor

Thanks for the contribution! You’ve checked boxes in the PR checklist above that are not reflected in this PR, so I’m assuming this is a work in progress and am marking it as a Draft. Please review the checklist, updating the PR as appropriate, and when the checklist reflects the state of the PR as posted please feel free to mark it as ready for review.

@stuartmorgan-g stuartmorgan-g marked this pull request as draft September 14, 2021 18:59
@stuartmorgan-g
Copy link
Contributor

Thank you for your contribution. I'm going to close this PR for now since there are outstanding comments, just to get this off our PR review queue. Please don't hesitate to submit a new PR if you have the time to address the review comments. Thanks!

@mhbdev
Copy link
Author

mhbdev commented Mar 23, 2022

Can you check this out please. This will solve the exception. I forgot to check the boxes when I was done with it. @stuartmorgan

@mhbdev
Copy link
Author

mhbdev commented Mar 23, 2022

In response to rrousselGit I have to say that you are totally right. This problem appears when there is no known duration for a video like in streams. This fix will avoid exceptions while loading this kind of videos.

@stuartmorgan-g
Copy link
Contributor

Can you check this out please. This will solve the exception. I forgot to check the boxes when I was done with it. @stuartmorgan

Please see my original comment above; once you've completed the steps there we can review the PR. Feel free to re-open it (or file a new PR if that's easier) once you have done them.

@ditman
Copy link
Member

ditman commented Jul 14, 2022

I've posted a PR that should fix this issue: #6101

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants