fijkplayer icon indicating copy to clipboard operation
fijkplayer copied to clipboard

[BUG] setDataSource() occurs an error

Open yoonjiyong opened this issue 5 years ago • 1 comments

Here is my code

import 'package:fijkplayer/fijkplayer.dart'; import 'package:flutter/material.dart';

class VideoTest extends StatefulWidget { // static const id = 'VideoTest'; @override _VideoTestState createState() => _VideoTestState(); }

class _VideoTestState extends State { var player; // VideoListController _videoListController = VideoListController();

@override void initState() { super.initState(); // player.reset();/**/ }

@override void didChangeDependencies() { super.didChangeDependencies(); player = FijkPlayer().setDataSource( ✅✅✅✅✅✅ HERE This line occurs an error that makes my app die 'http://baishan.oversketch.com/2019/11/05/d07f2f1440e51b9680f4bcfe63b0ab67.MP4', autoPlay: true); }

@override Widget build(BuildContext context) { return Scaffold( body: Container( color: Colors.green, // child: Center( // child: FijkView( // fit: FijkFit.fitHeight, // player: player, // color: Colors.black, // panelBuilder: (_, __, ___, ____, _____) => Container(), // ), // ), ), ); } }

`

I'm on iPhone7 real device I have no idea

This is error log flutter: [inf] 2020-12-15 15:12:23.924225 [fijk] create player id:1 flutter: [inf] 2020-12-15 15:12:23.954624 [fijk] FijkPlayer{id:1} invoke setDataSource http://baishan.oversketch.com/2019/11/05/d07f2f1440e51b9680f4bcfe63b0ab67.MP4 flutter: [inf] 2020-12-15 15:12:23.965312 [fijk] FijkPlayer{id:1} state changed to FijkState.initialized <= FijkState.idle flutter: [inf] 2020-12-15 15:12:23.968244 [fijk] FijkPlayer{id:1} invoke prepareAsync and start #1 flutter: [inf] 2020-12-15 15:12:23.969197 [fijk] FijkPlayer{id:1} setOption k:start-on-prepared, v:1 flutter: [inf] 2020-12-15 15:12:23.978748 [fijk] FijkPlayer{id:1} state changed to FijkState.asyncPreparing <= FijkState.initialized flutter: [inf] 2020-12-15 15:12:23.979854 [fijk] FijkPlayer{id:1} invoke prepareAsync and start #1 -> done flutter: [inf] 2020-12-15 15:12:23.980665 [fijk] FijkPlayer{id:1} state changed to FijkState.initialized <= FijkState.idle flutter: [inf] 2020-12-15 15:12:23.982012 [fijk] FijkPlayer{id:1} state changed to FijkState.asyncPreparing <= FijkState.initialized Lost connection to device.

yoonjiyong avatar Dec 15 '20 06:12 yoonjiyong

This is just a bad code error not the package. The variable player has not been initialized neither have you updated its state but assigned a new instance of FijkPlayer

FijkPlayer player;

@override 
void initState{
 player = FijkPlayer()
 ..setDataSource([CONFIGURE YOUR DATA]);
 super.initState();
}

...

Michael24884 avatar May 15 '21 17:05 Michael24884