Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
netrain_flutter_app
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
邹志胜
netrain_flutter_app
Commits
57b5ca71
Commit
57b5ca71
authored
Jul 29, 2021
by
“Icebear”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加视频播放,2种库
parent
05678ce9
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
215 additions
and
20 deletions
+215
-20
main.dart
netrain_flutter_app/lib/main.dart
+74
-18
fijkplayer.dart
...ain_flutter_app/lib/zhangfeng/VideoPlayer/fijkplayer.dart
+51
-0
video_player.dart
...n_flutter_app/lib/zhangfeng/VideoPlayer/video_player.dart
+48
-0
WatchModel.dart
netrain_flutter_app/lib/zhangfeng/WatchModel.dart
+13
-0
WatchModel.g.dart
netrain_flutter_app/lib/zhangfeng/WatchModel.g.dart
+20
-0
pubspec.yaml
netrain_flutter_app/pubspec.yaml
+9
-2
No files found.
netrain_flutter_app/lib/main.dart
View file @
57b5ca71
...
@@ -12,6 +12,7 @@ import 'package:netrain_flutter_app/common/AppColors.dart';
...
@@ -12,6 +12,7 @@ import 'package:netrain_flutter_app/common/AppColors.dart';
import
'package:netrain_flutter_app/xuehao/grid_page.dart'
;
import
'package:netrain_flutter_app/xuehao/grid_page.dart'
;
import
'package:netrain_flutter_app/xuehao/list_page.dart'
;
import
'package:netrain_flutter_app/xuehao/list_page.dart'
;
import
'package:provider/provider.dart'
;
import
'package:provider/provider.dart'
;
import
'package:video_player/video_player.dart'
;
import
'laishanqi/Stateful_page.dart'
;
import
'laishanqi/Stateful_page.dart'
;
import
'laishanqi/Stateless_page.dart'
;
import
'laishanqi/Stateless_page.dart'
;
...
@@ -27,6 +28,8 @@ import 'zhangfeng/CustomTabPage.dart';
...
@@ -27,6 +28,8 @@ import 'zhangfeng/CustomTabPage.dart';
import
'zhangfeng/TestPage.dart'
;
import
'zhangfeng/TestPage.dart'
;
import
'zhangfeng/TabBarPage.dart'
;
import
'zhangfeng/TabBarPage.dart'
;
import
'zhangfeng/LayoutDemo.dart'
;
import
'zhangfeng/LayoutDemo.dart'
;
import
'zhangfeng/VideoPlayer/video_player.dart'
;
import
'zhangfeng/VideoPlayer/fijkplayer.dart'
;
import
'jishuaishuai/firstVC.dart'
;
import
'jishuaishuai/firstVC.dart'
;
...
@@ -93,6 +96,8 @@ class MyApp extends StatelessWidget {
...
@@ -93,6 +96,8 @@ class MyApp extends StatelessWidget {
"LoginRequestPage"
:
(
context
)
=>
LoginRequestPage
(),
"LoginRequestPage"
:
(
context
)
=>
LoginRequestPage
(),
"PageView"
:
(
context
)
=>
SampleAppPage
(),
"PageView"
:
(
context
)
=>
SampleAppPage
(),
"LayoutDemo"
:
(
context
)
=>
LayoutDemo
(),
"LayoutDemo"
:
(
context
)
=>
LayoutDemo
(),
"Video"
:
(
context
)
=>
Video
(),
"VideoScreen"
:
(
context
)
=>
VideoScreen
(),
"main"
:
(
context
)
=>
mainPage
(
context
),
"main"
:
(
context
)
=>
mainPage
(
context
),
"firstVC"
:
(
context
)
=>
jssPageDemo
(),
"firstVC"
:
(
context
)
=>
jssPageDemo
(),
"car_details"
:
(
context
)
=>
CarDetailsPage
(),
"car_details"
:
(
context
)
=>
CarDetailsPage
(),
...
@@ -135,8 +140,7 @@ class _RouterNavigatorState extends State<RouterNavigator> {
...
@@ -135,8 +140,7 @@ class _RouterNavigatorState extends State<RouterNavigator> {
return
Container
(
return
Container
(
child:
Container
(
child:
Container
(
margin:
EdgeInsets
.
only
(
left:
10
,
right:
10
),
margin:
EdgeInsets
.
only
(
left:
10
,
right:
10
),
child:
Wrap
(
child:
Column
(
spacing:
10
,
children:
[
children:
[
SwitchListTile
(
SwitchListTile
(
title:
Text
(
'
${byName ? '' : '不'}
通过路由名跳转'
),
title:
Text
(
'
${byName ? '' : '不'}
通过路由名跳转'
),
...
@@ -146,23 +150,61 @@ class _RouterNavigatorState extends State<RouterNavigator> {
...
@@ -146,23 +150,61 @@ class _RouterNavigatorState extends State<RouterNavigator> {
byName
=
value
;
byName
=
value
;
});
});
}),
}),
Container
(
child:
Column
(
children:
[
Padding
(
padding:
EdgeInsets
.
all
(
10
)),
Wrap
(
spacing:
10
,
children:
[
_item
(
"登陆"
,
LoginPage
(),
'login'
,
context
),
_item
(
"登陆"
,
LoginPage
(),
'login'
,
context
),
_item
(
"首页"
,
LessGroupPage
(),
'doctor_MainPage'
,
context
),
_item
(
"首页"
,
LessGroupPage
(),
'doctor_MainPage'
,
context
),
_item
(
"less页面"
,
LessGroupPage
(),
'less'
,
context
),
_item
(
"less页面"
,
LessGroupPage
(),
'less'
,
context
),
_item
(
"ful页面"
,
FulGroupPage
(),
'ful'
,
context
),
_item
(
"ful页面"
,
FulGroupPage
(),
'ful'
,
context
),
_item
(
"layout页面"
,
LayoutPage
(),
'layout'
,
context
),
_item
(
"layout页面"
,
LayoutPage
(),
'layout'
,
context
),
_item
(
"拍照页面"
,
PhotoApp
(),
'photo'
,
context
),
_item
(
"拍照页面"
,
PhotoApp
(),
'photo'
,
context
),
],
),
],
),
),
Container
(
child:
Column
(
children:
[
Padding
(
padding:
EdgeInsets
.
all
(
10
)),
Wrap
(
spacing:
10
,
children:
[
_item
(
"登录网络请求"
,
LoginRequestPage
(),
'LoginRequestPage'
,
context
),
_item
(
"登录网络请求"
,
LoginRequestPage
(),
'LoginRequestPage'
,
context
),
_item
(
"CustomTabPage"
,
TabBarPage
(),
'CustomTabPage'
,
context
),
_item
(
"CustomTabPage"
,
TabBarPage
(),
'CustomTabPage'
,
context
),
_item
(
"PageView"
,
SampleAppPage
(),
'PageView'
,
context
),
_item
(
"PageView"
,
SampleAppPage
(),
'PageView'
,
context
),
_item
(
"LayoutDemo"
,
LayoutDemo
(),
'LayoutDemo'
,
context
),
_item
(
"LayoutDemo"
,
LayoutDemo
(),
'LayoutDemo'
,
context
),
_item
(
"listview页面"
,
List_Page
(),
'listPage'
,
context
),
_item
(
"listview页面"
,
List_Page
(),
'listPage'
,
context
),
_item
(
"VideoPlay页面"
,
Video
(),
'Video'
,
context
),
_item
(
"Fijkplayer"
,
VideoScreen
(),
'VideoScreen'
,
context
),
],
),
],
),
),
Container
(
child:
Column
(
children:
[
Padding
(
padding:
EdgeInsets
.
all
(
10
)),
Wrap
(
spacing:
10
,
children:
[
_item
(
"jssDemo"
,
jssPageDemo
(),
'firstVC'
,
context
),
_item
(
"jssDemo"
,
jssPageDemo
(),
'firstVC'
,
context
),
_item
(
"jssDemo"
,
jssPageDemo
(),
'student'
,
context
),
_item
(
"jssDemo"
,
jssPageDemo
(),
'student'
,
context
),
_item
(
"gridView"
,
GridPage
(),
'grid_page'
,
context
),
_item
(
"gridView"
,
GridPage
(),
'grid_page'
,
context
),
_item
(
"BottomNav"
,
BottomNavPage
(),
'bottom_page'
,
context
),
_item
(
"BottomNav"
,
BottomNavPage
(),
'bottom_page'
,
context
),
],
],
),
),
],
),
)
],
),
),
),
);
);
}
}
...
@@ -173,7 +215,21 @@ class _RouterNavigatorState extends State<RouterNavigator> {
...
@@ -173,7 +215,21 @@ class _RouterNavigatorState extends State<RouterNavigator> {
onPressed:
()
{
onPressed:
()
{
// Navigator.of(context).push(route)
// Navigator.of(context).push(route)
if
(
byName
)
{
if
(
byName
)
{
if
(
routeName
==
'Video'
||
routeName
==
'VideoScreen'
){
Navigator
.
push
(
context
,
PageRouteBuilder
(
transitionDuration:
Duration
(
milliseconds:
500
),
//动画时间为500毫秒
pageBuilder:
(
BuildContext
context
,
Animation
animation
,
Animation
secondaryAnimation
)
{
return
new
FadeTransition
(
//使用渐隐渐入过渡,
opacity:
animation
,
child:
(
routeName
==
'Video'
?
Video
()
:
VideoScreen
()),
//路由B
);
}
));
}
else
{
Navigator
.
pushNamed
(
context
,
routeName
);
Navigator
.
pushNamed
(
context
,
routeName
);
}
}
else
{
}
else
{
Navigator
.
push
(
Navigator
.
push
(
context
,
context
,
...
...
netrain_flutter_app/lib/zhangfeng/VideoPlayer/fijkplayer.dart
0 → 100644
View file @
57b5ca71
import
'package:fijkplayer/fijkplayer.dart'
;
import
'package:flutter/material.dart'
;
class
VideoScreen
extends
StatefulWidget
{
final
String
url
=
'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4'
;
// VideoScreen({@required this.url});
@override
_VideoScreenState
createState
()
=>
_VideoScreenState
();
}
class
_VideoScreenState
extends
State
<
VideoScreen
>
{
final
FijkPlayer
player
=
FijkPlayer
();
_VideoScreenState
();
@override
void
initState
()
{
super
.
initState
();
player
.
setDataSource
(
widget
.
url
,
autoPlay:
true
);
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
backgroundColor:
Colors
.
black
,
title:
Text
(
'视频播放'
),
leading:
GestureDetector
(
onTap:
()
{
Navigator
.
pop
(
context
);
},
child:
Container
(
child:
Icon
(
Icons
.
close
,
color:
Colors
.
white
)),
),
),
body:
Container
(
alignment:
Alignment
.
center
,
child:
FijkView
(
color:
Colors
.
black
,
player:
player
,
),
));
}
@override
void
dispose
()
{
super
.
dispose
();
player
.
release
();
}
}
\ No newline at end of file
netrain_flutter_app/lib/zhangfeng/VideoPlayer/video_player.dart
0 → 100644
View file @
57b5ca71
import
'package:flutter/material.dart'
;
import
'package:chewie/chewie.dart'
;
//chewie插件导入
import
'package:video_player/video_player.dart'
;
//video_player插件导入
class
Video
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
title:
'Flutter视频播放'
,
theme:
ThemeData
(
primarySwatch:
Colors
.
blue
,
),
home:
Scaffold
(
appBar:
AppBar
(
backgroundColor:
Colors
.
white
,
title:
Text
(
'视频播放'
),
leading:
GestureDetector
(
onTap:
()
{
Navigator
.
pop
(
context
);
},
child:
Container
(
child:
Icon
(
Icons
.
close
,
color:
Colors
.
black
)),
),
),
body:
viDeoPlayer
(),
//播放控件放在这里调用
),
);
}
}
//******************建议视频播放控件封装成类或函数************************
Widget
viDeoPlayer
(
)
{
var
usr
=
'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4'
;
// 视频播放地址
//视频播放控件设置
Widget
playerWidget
=
Chewie
(
controller:
ChewieController
(
videoPlayerController:
VideoPlayerController
.
network
(
usr
),
//播放的视频地址写在这里
aspectRatio:
4
/
3
,
//屏幕高宽比
autoPlay:
true
,
//是否自动播放
looping:
false
,
//是否循环播放
// fullScreenByDefault:true, //默认情况下全屏
//isLive:true, //视频长度替换成live字样
),
);
return
playerWidget
;
//返回
}
\ No newline at end of file
netrain_flutter_app/lib/zhangfeng/WatchModel.dart
0 → 100644
View file @
57b5ca71
import
'package:json_annotation/json_annotation.dart'
;
part
'WatchModel.g.dart'
;
@JsonSerializable
()
class
WatchModel
{
String
name
;
String
watchId
;
WatchModel
(
this
.
name
,
this
.
watchId
);
factory
WatchModel
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
_$WatchModelFromJson
(
json
);
Map
<
String
,
dynamic
>
toJson
()
=>
_$WatchModelToJson
(
this
);
}
\ No newline at end of file
netrain_flutter_app/lib/zhangfeng/WatchModel.g.dart
0 → 100644
View file @
57b5ca71
// GENERATED CODE - DO NOT MODIFY BY HAND
part of
'WatchModel.dart'
;
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
WatchModel
_$WatchModelFromJson
(
Map
<
String
,
dynamic
>
json
)
{
return
WatchModel
(
json
[
'name'
]
as
String
,
json
[
'watchId'
]
as
String
,
);
}
Map
<
String
,
dynamic
>
_$WatchModelToJson
(
WatchModel
instance
)
=>
<
String
,
dynamic
>{
'name'
:
instance
.
name
,
'watchId'
:
instance
.
watchId
,
};
netrain_flutter_app/pubspec.yaml
View file @
57b5ca71
...
@@ -33,7 +33,7 @@ dependencies:
...
@@ -33,7 +33,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons
:
^
0.1
.3
cupertino_icons
:
^
1.0
.3
image_picker
:
0.7.4
image_picker
:
0.7.4
fluttertoast
:
^3.1.3
fluttertoast
:
^3.1.3
http
:
0.13.3
http
:
0.13.3
...
@@ -46,8 +46,15 @@ dependencies:
...
@@ -46,8 +46,15 @@ dependencies:
pull_to_refresh
:
^2.0.0
pull_to_refresh
:
^2.0.0
flustars
:
^2.0.1
#强大的工具类库
flustars
:
^2.0.1
#强大的工具类库
shared_preferences
:
^2.0.6
shared_preferences
:
^2.0.6
provider
:
^
4.1
.0
provider
:
^
5.0
.0
# chewie的依赖
video_player
:
^2.1.12
# 视频播放
chewie
:
^1.2.2
#fijkplayer
fijkplayer
:
^0.10.0
dev_dependencies
:
dev_dependencies
:
flutter_test
:
flutter_test
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment