Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
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
abdullh.alsoleman
Front-End
Commits
b46d7904
Unverified
Commit
b46d7904
authored
Dec 05, 2017
by
Sigurd Meldgaard
Committed by
GitHub
Dec 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spinner to loading video (#13330)
* Add spinner to loading video
parent
ffb24eda
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
31 deletions
+69
-31
video_demo.dart
examples/flutter_gallery/lib/demo/video_demo.dart
+68
-30
pubspec.yaml
examples/flutter_gallery/pubspec.yaml
+1
-1
No files found.
examples/flutter_gallery/lib/demo/video_demo.dart
View file @
b46d7904
...
...
@@ -30,7 +30,7 @@ class VideoCard extends StatelessWidget {
aspectRatio:
3
/
2
,
child:
new
Hero
(
tag:
controller
,
child:
new
VideoPlayer
(
controller
),
child:
new
VideoPlayer
Loading
(
controller
),
),
),
),
...
...
@@ -97,6 +97,50 @@ class VideoCard extends StatelessWidget {
}
}
class
VideoPlayerLoading
extends
StatefulWidget
{
final
VideoPlayerController
controller
;
const
VideoPlayerLoading
(
this
.
controller
);
@override
_VideoPlayerLoadingState
createState
()
=>
new
_VideoPlayerLoadingState
();
}
class
_VideoPlayerLoadingState
extends
State
<
VideoPlayerLoading
>
{
bool
_initialized
;
@override
void
initState
()
{
super
.
initState
();
_initialized
=
widget
.
controller
.
value
.
initialized
;
widget
.
controller
.
addListener
(()
{
if
(!
mounted
)
{
return
;
}
final
bool
controllerInitialized
=
widget
.
controller
.
value
.
initialized
;
if
(
_initialized
!=
controllerInitialized
)
{
setState
(()
{
_initialized
=
controllerInitialized
;
});
}
});
}
@override
Widget
build
(
BuildContext
context
)
{
if
(
_initialized
)
{
return
new
VideoPlayer
(
widget
.
controller
);
}
return
new
Stack
(
children:
<
Widget
>[
new
VideoPlayer
(
widget
.
controller
),
const
Center
(
child:
const
CircularProgressIndicator
()),
],
fit:
StackFit
.
expand
,
);
}
}
class
VideoPlayPause
extends
StatefulWidget
{
final
VideoPlayerController
controller
;
...
...
@@ -132,37 +176,31 @@ class _VideoPlayPauseState extends State<VideoPlayPause> {
@override
Widget
build
(
BuildContext
context
)
{
final
List
<
Widget
>
children
=
<
Widget
>[
new
GestureDetector
(
child:
new
VideoPlayer
(
controller
),
onTap:
()
{
if
(!
controller
.
value
.
initialized
)
{
return
;
}
if
(
controller
.
value
.
isPlaying
)
{
imageFadeAnimation
=
new
FadeAnimation
(
child:
new
Icon
(
Icons
.
pause
,
size:
100.0
),
);
controller
.
pause
();
}
else
{
imageFadeAnimation
=
new
FadeAnimation
(
child:
new
Icon
(
Icons
.
play_arrow
,
size:
100.0
),
);
controller
.
play
();
}
},
),
new
Center
(
child:
imageFadeAnimation
),
];
if
(!
controller
.
value
.
initialized
)
{
children
.
add
(
new
Container
());
}
return
new
Stack
(
alignment:
Alignment
.
bottomCenter
,
fit:
StackFit
.
passthrough
,
children:
children
,
fit:
StackFit
.
expand
,
children:
<
Widget
>[
new
GestureDetector
(
child:
new
VideoPlayerLoading
(
controller
),
onTap:
()
{
if
(!
controller
.
value
.
initialized
)
{
return
;
}
if
(
controller
.
value
.
isPlaying
)
{
imageFadeAnimation
=
new
FadeAnimation
(
child:
new
Icon
(
Icons
.
pause
,
size:
100.0
),
);
controller
.
pause
();
}
else
{
imageFadeAnimation
=
new
FadeAnimation
(
child:
new
Icon
(
Icons
.
play_arrow
,
size:
100.0
),
);
controller
.
play
();
}
},
),
new
Center
(
child:
imageFadeAnimation
),
],
);
}
}
...
...
examples/flutter_gallery/pubspec.yaml
View file @
b46d7904
...
...
@@ -8,7 +8,7 @@ dependencies:
string_scanner
:
1.0.2
url_launcher
:
0.4.2+5
cupertino_icons
:
0.1.1
video_player
:
0.0.
5
video_player
:
0.0.
6
# Also update dev/benchmarks/complex_layout/pubspec.yaml
flutter_gallery_assets
:
...
...
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