2

I am developing flutter app and using ext_video_player for play youtube video. When i was play my channel video on video player, its didn't work. But i add any video from youtube, player is working. Why its happening?

import 'package:ext_video_player/ext_video_player.dart';

controller = VideoPlayerController.network(
    //example video
    'https://www.youtube.com/watch?v=TdrL3QxjyVw'  
    //my video
    //'https://www.youtube.com/watch?v=GoqggeA-ctA'
      )
    ..initialize().then((value) {
      controller.setLooping(true);
      controller.play();
      widget.sets.controller = controller;
      widget.onInitialized();
    });

Widget build(BuildContext context) => SizedBox(
    child: controller.value.initialized
        ? VideoPlayer(controller)
        : Center(child: CircularProgressIndicator()),
  );
  • working video 'https://www.youtube.com/watch?v=TdrL3QxjyVw'
  • my video (didn't work) 'https://www.youtube.com/watch?v=GoqggeA-ctA'

Error :

I/ExoPlayerImpl( 4553): Init 16226c0 [ExoPlayerLib/2.13.2] [generic_x86_arm, sdk_gphone_x86, Google, 30]
E/ExoPlayerImplInternal( 4553): Playback error
E/ExoPlayerImplInternal( 4553):   com.google.android.exoplayer2.ExoPlaybackException: Source error
E/ExoPlayerImplInternal( 4553):       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:579)
E/ExoPlayerImplInternal( 4553):       at android.os.Handler.dispatchMessage(Handler.java:102)
E/ExoPlayerImplInternal( 4553):       at android.os.Looper.loop(Looper.java:223)
E/ExoPlayerImplInternal( 4553):       at android.os.HandlerThread.run(HandlerThread.java:67)
E/ExoPlayerImplInternal( 4553):   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, JpegExtractor) could read the stream.
E/ExoPlayerImplInternal( 4553):       at com.google.android.exoplayer2.source.BundledExtractorsAdapter.init(BundledExtractorsAdapter.java:92)
E/ExoPlayerImplInternal( 4553):       at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1026)
E/ExoPlayerImplInternal( 4553):       at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:415)
E/ExoPlayerImplInternal( 4553):       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/ExoPlayerImplInternal( 4553):       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/ExoPlayerImplInternal( 4553):       at java.lang.Thread.run(Thread.java:923)
E/flutter ( 4553): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: Source error, null, null)

Thanks, Have a nice days.

Mortis Causa
  • 41
  • 1
  • 6
  • 1
    Have you considered using `youtube_player_flutter` instead from https://pub.dev/packages/youtube_player_flutter to play youtube videos – Sisir Feb 27 '21 at 19:14
  • Thank you for advice. Yes i considered. But i must to use VideoPlayerController in my code, so i don't use it.. – Mortis Causa Feb 27 '21 at 19:22
  • Video play has to have particular format of video to be played. This link would probably be invalid. Way around would be to parse this url to get actual video file link in `.mp4` or other to be able to play. – Anil Poudyal Jul 19 '21 at 04:47

2 Answers2

2

Problem is caused by uploading format for youtube. When i mp4 file convert to mp4 with h.264 + aac codec and upload youtube then player play my video. Its upload format problem.

Mortis Causa
  • 41
  • 1
  • 6
0

use the youtube_player_flutter package with the version: youtube_player_flutter: ^ 6.1.1

here is my example of the code to retrieve videos from a youtube channel

class Video {
  final String id;
  final String title;
  final String thumbnailUrl;
  final String channelTitle;

  Video({
    this.id,
    this.title,
    this.thumbnailUrl,
    this.channelTitle,
  });

  factory Video.fromMap(Map<String, dynamic> snippet) {
    return Video(
      id: snippet['resourceId']['videoId'],
      title: snippet['title'],
      thumbnailUrl: snippet['thumbnails']['high']['url'],
      channelTitle: snippet['channelTitle'],
    );
  }
}
  • Thanks for answer. But i must to use VideoPlayerController in my code. My problem, why my youtube videos didn't play. Although other youtube videos are working. – Mortis Causa Feb 27 '21 at 22:56