Skip to content
Advertisement

Flutter is unable to display video

JavaScript

Even though I had tried adding the dependencies and change the video link to a YouTube link instead, it still the same and does not display the video. May I know how to solve this problem? There are a few errors, I listed it as below:

  1. The method ‘VideoPlayer’ isn’t defined for the type ‘_VideoAppState’
  2. Undefined name ‘VideoPlayerController’.
  3. Undefined class ‘VideoPlayerController’.
  4. Target of URI doesn’t exist: ‘package:video_player/video_player.dart’

Pubspec.yml below

JavaScript

@Tommie C. The below are the errors that I experienced when running the codes:

JavaScript

Advertisement

Answer

Update:

Nota Bene: In the sample below, you can comment out the line trying to load the srt subtitles file (closedCaptionFile: _loadCaptions,).

Change the following in your pubspec.yaml to video_player: ^2.1.15

Note – Also, are you trying to run this in iOS or Android? Make sure you open the Runner.xcworkspace file and perform the standard Xcode routines. Make sure that the Runner project and the pods project is visible. Try running flutter build ios from the terminal.

Then re-run flutter pub get or click get Dependencies in the UI. I’d also make a demo project (stub – flutter create --org com.yoursite stub01) and add the sample provided to see if the online sample is working.

Original:

Here is the complete sample from the plugin website for the video_player. You can paste it into your environment to be certain that everything is working. You should also make sure that you are following the setup steps where you give your iOS/Android app permission to access the internet (see the installation notes on the readme section of the website). I’d also make sure to run flutter upgrade on your terminal.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement