1

I am trying to play a vimeo video in a flutter app using the video player library.

I have followed the example given for video_player. When I launch the screen and my android emulator, I am getting the following exception thrown....

I/ExoPlayerImpl( 8462): Release 1ac4175 [ExoPlayerLib/2.12.1] [generic_x86_64, Android SDK built for x86_64, Google, 28] [goog.exo.core]
I/ExoPlayerImpl( 8462): Init b7aeab8 [ExoPlayerLib/2.12.1] [generic_x86_64, Android SDK built for x86_64, Google, 28]
E/ExoPlayerImplInternal( 8462): Playback error
E/ExoPlayerImplInternal( 8462):   com.google.android.exoplayer2.ExoPlaybackException: Source error
E/ExoPlayerImplInternal( 8462):       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:554)
E/ExoPlayerImplInternal( 8462):       at android.os.Handler.dispatchMessage(Handler.java:102)
E/ExoPlayerImplInternal( 8462):       at android.os.Looper.loop(Looper.java:193)
E/ExoPlayerImplInternal( 8462):       at android.os.HandlerThread.run(HandlerThread.java:65)
E/ExoPlayerImplInternal( 8462):   Caused by: com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (FlvExtractor, FlacExtractor, WavExtractor, FragmentedMp4Extractor, Mp4Extractor, AmrExtractor, PsExtractor, OggExtractor, TsExtractor, MatroskaExtractor, AdtsExtractor, Ac3Extractor, Ac4Extractor, Mp3Extractor) could read the stream.
E/ExoPlayerImplInternal( 8462):       at com.google.android.exoplayer2.source.BundledExtractorsAdapter.init(BundledExtractorsAdapter.java:92)
E/ExoPlayerImplInternal( 8462):       at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1024)
E/ExoPlayerImplInternal( 8462):       at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:415)
E/ExoPlayerImplInternal( 8462):       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/ExoPlayerImplInternal( 8462):       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/ExoPlayerImplInternal( 8462):       at java.lang.Thread.run(Thread.java:764)

My code is as follows...

import 'package:flutter/material.dart';
import 'package:sidekicktool/values.dart';
import 'package:video_player/video_player.dart';

class HomeScreen extends StatefulWidget {
  HomeScreen({Key key}) : super(key: key);

  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {

  final _key = UniqueKey();  
  VideoPlayerController _controller;

  @override
  void initState() { 
    super.initState();
    _controller = VideoPlayerController.network(
        'https://vimeo.com/476379279')
      ..initialize().then((_) {
        // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
        setState(() {});
      });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.Background,
      appBar: AppBar(
        centerTitle: true,
        backgroundColor: Colors.Primary,
        title: Text(
          'HOME',
          style:Styles.ButtonTextStyle.copyWith(color: Colors.PrimaryContrast)
        )
      ),
      body: Center(
        child: _controller.value.initialized
          ? AspectRatio(
              aspectRatio: _controller.value.aspectRatio,
              child: VideoPlayer(_controller),
            )
          : Container(),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {
            _controller.value.isPlaying
                ? _controller.pause()
                : _controller.play();
          });
        },
        child: Icon(
          _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
        )
      )
    );
  }
} 
Scorb
  • 1,654
  • 13
  • 70
  • 144

2 Answers2

1

You can't play video Vimeo links in video_player.

You must provide a video source which ends with video format.

Example http://www.sample-videos.com/video123/mp4/720/big_buck_bunny_720p_20mb.mp4

May this helps you : video_player example

K_mns
  • 683
  • 4
  • 10
1

if you want to get mp4 link of vimeo video then in url search [https://player.vimeo.com/video/13083500/config] And whatever video you want edit the video no in link. here you will get json file grab the mp4 link from source. Happy coding..