class VideoPlayPage extends StatefulWidget {
const VideoPlayPage(
{Key key, this.url,this.name,this.index})
: super(key: key);
final String url;
final String name;
final int index;
@override
_VideoPlayPageState createState() => new _VideoPlayPageState(this.url,this.name,this.index);
}
class _VideoPlayPageState extends State {
_VideoPlayPageState(this.url,this.name,this.index);
final String url;
final String name;
final int index;
视频可以在浏览器上播放,但是在flutter app 上不可以 报错如下 flutter: 日志拦截: http://192.168.100.8:8081/file?p=/video/2020/05/IMG_3761.mp4 [VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: 'package:flutter/src/foundation/stack_frame.dart': Failed assertion: line 113 pos 12: 'match != null': Expected to match RegExp: pattern=^(.+) (\d+):(\d+)\s+(.+)$ flags=.
0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:42:39)
1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:38:5)
2 StackFrame._parseWebDebugFrame (package:flutter/src/foundation/stack_frame.dart:113:12)
3 StackFrame._parseWebFrame (package:flutter/src/foundation/stack_frame.dart:99:14)
4 StackFrame.fromStackTraceLine (package:flutter/src/foundation/stack_frame.dart:193:14)
5 MappedListIterable.elementAt (dart:_internal/iterable.dart:417:31)
6 ListIterator.moveNext (dart:_internal/iterable.dart:346:26)
7 SkipWhileIterator.moveNext (dart:_internal/iterable.dart:669:24)
8 new List.from (dart:core-patch/array_patch.dart:47:19)
9 Iterable.toList (dart:core/iterable.dart:400:12)
10 StackFrame.fromStackString (package:flutter/src/foundation/stack_frame.dart:94:10)
11 FlutterError.defaultStackFilter (package:flutter/src/foundation/assertions.dart:820:54)
12 new DiagnosticsStackTrace (package:flutter/src/foundation/assertions.dart:958:59)
13 FlutterErrorDetails.debugFillProperties (package:flutter/src/foundation/assertions.dart:575:22)
14 DiagnosticableNode.builder. (package:flutter/src/foundation/diagnostics.dart:2926:18)
15 DiagnosticableNode.builder (package:flutter/src/foundation/diagnostics.dart:2929:8)
16 _FlutterErrorDetailsNode.builder (package:flutter/src/foundation/assertions.dart:996:55)
17 DiagnosticableNode.getProperties (package:flutter/src/foundation/diagnostics.dart:2943:105)
18 TextTreeRenderer._debugRender (package:flutter/src/foundation/diagnostics.dart:1238:63)
19 TextTreeRenderer.render (package:flutter/src/foundation/diagnostics.dart:1116:14)
20 DiagnosticsNode.toStringDeep. (package:flutter/src/foundation/diagnostics.dart:1730:9)
21 DiagnosticsNode.toStringDeep (package:flutter/src/foundation/diagnostics.dart:1737:6)
22 FlutterErrorDetails.toString (package:flutter/src/foundation/assertions.dart:590:65)
23 _StringBase._interpolateSingle (dart:core-patch/string_patch.dart:823:17)
24 print (dart:core/print.dart:11:26)
25 AppInit.reportErrorAndLog (package:iCloud/init/app_init.dart:44:5)
26 AppInit.catchException. (package:iCloud/init/app_init.dart:32:9)
27 _rootRunBinary (dart:async/zone.dart:1208:13)
28 _CustomZone.runBinary (dart:async/zone.dart:1093:19)
29 runZonedGuarded. (dart:async/zone.dart:1591:19)
30 _CustomZone.handleUncaughtError (dart:async/zone.dart:1059:19)
31 Future._propagateToListeners (dart:async/future_impl.dart:598:16)
32 Future._completeError (dart:async/future_impl.dart:534:5)
33 Future._asyncCompleteError. (dart:async/future_impl.dart:582:7)
34 _rootRun (dart:async/zone.dart:1184:13)
35 _CustomZone.run (dart:async/zone.dart:1077:19)
36 _CustomZone.runGuarded (dart:async/zone.dart:979:7)
37 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1019:23)
38 _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
39 _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
代码如下:
import 'package:flutter/material.dart'; import 'package:awsome_video_player/awsome_video_player.dart'; import 'package:iCloud/page/fintness_app_theme.dart';
class VideoPlayPage extends StatefulWidget { const VideoPlayPage( {Key key, this.url,this.name,this.index}) : super(key: key); final String url; final String name; final int index;
@override _VideoPlayPageState createState() => new _VideoPlayPageState(this.url,this.name,this.index); }
class _VideoPlayPageState extends State {
_VideoPlayPageState(this.url,this.name,this.index);
final String url; final String name; final int index;
String mainSubtitles = ""; //主字幕 String subSubtitles = ""; //辅字幕 bool _isPlaying = false; bool _isFullscreen = false;
bool showAdvertCover = false; //是否显示广告
bool get isPlaying => _isPlaying; set isPlaying(bool playing) { print("playing $playing"); _isPlaying = playing; }
@override void initState() { super.initState(); }
@override Widget build(BuildContext context) { print(url); return MaterialApp( home: Container( color: FintnessAppTheme.background, child: Scaffold( backgroundColor: Colors.transparent, appBar: !_isFullscreen ? AppBar( leading: IconButton(icon: new Icon(Icons.chevron_left)), backgroundColor: FintnessAppTheme.background, automaticallyImplyLeading: true, title: Text(name,style: TextStyle( color: Colors.black38 ),),
// contents: [ // Center( // child: Container( // margin: EdgeInsets.symmetric(horizontal: 10), // child: Text( // '返回', // style: TextStyle( // color: Colors.white, fontSize: 14), // ), // ), // ) // ], //自定义顶部控制栏中间显示区域 // actions: [ // GestureDetector( // onTap: () { // ///1. 可配合自定义拓展元素使用,例如广告 // setState(() { // showAdvertCover = true; // }); // // /// // }, // child: Icon( // Icons.more_horiz, // size: 16, // color: Colors.white, // ), // ) // ], //自定义顶部控制栏右侧显示区域 /// 设置cusotmBar之后,以上属性均无效(除了
show
之外) // customBar: Positioned( // top: 0, // left: 0, // right: 0, // child: Container( // width: double.infinity, // height: 50, // color: Colors.yellow, // child: Text("12312312"), // ), // ), // customBar: Align( // alignment: Alignment.topLeft, // child: Container( // width: double.infinity, // height: 30, // color: Colors.yellow, // child: GestureDetector( // onTap: () { // print("yes"); // }, // child: Text("123123132") // ) // ), // ), ),} }