Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OnePoem
/
OnePoem-App
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
reason
2021-12-29 20:08:07 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c45e99d6bba33b1d937d4c4e4a7aaec7b962df32
c45e99d6
1 parent
657ae96b
clear
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
72 additions
and
26 deletions
ios/Flutter/Debug.xcconfig
ios/Flutter/Release.xcconfig
ios/Podfile
lib/login/widgets/my_text_field.dart
lib/main.dart
lib/tiktok/controller/tiktok_video_list_controller.dart
pubspec.lock
ios/Flutter/Debug.xcconfig
View file @
c45e99d
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
...
...
ios/Flutter/Release.xcconfig
View file @
c45e99d
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
...
...
ios/Podfile
0 → 100644
View file @
c45e99d
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV
[
'COCOAPODS_DISABLE_STATS'
]
=
'true'
project
'Runner'
,
{
'Debug'
=>
:debug
,
'Profile'
=>
:release
,
'Release'
=>
:release
,
}
def
flutter_root
generated_xcode_build_settings_path
=
File
.
expand_path
(
File
.
join
(
'..'
,
'Flutter'
,
'Generated.xcconfig'
),
__FILE__
)
unless
File
.
exist?
(
generated_xcode_build_settings_path
)
raise
"
#{
generated_xcode_build_settings_path
}
must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File
.
foreach
(
generated_xcode_build_settings_path
)
do
|
line
|
matches
=
line
.
match
(
/FLUTTER_ROOT\=(.*)/
)
return
matches
[
1
].
strip
if
matches
end
raise
"FLUTTER_ROOT not found in
#{
generated_xcode_build_settings_path
}
. Try deleting Generated.xcconfig, then run flutter pub get"
end
require
File
.
expand_path
(
File
.
join
(
'packages'
,
'flutter_tools'
,
'bin'
,
'podhelper'
),
flutter_root
)
flutter_ios_podfile_setup
target
'Runner'
do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods
File
.
dirname
(
File
.
realpath
(
__FILE__
))
end
post_install
do
|
installer
|
installer
.
pods_project
.
targets
.
each
do
|
target
|
flutter_additional_ios_build_settings
(
target
)
end
end
lib/login/widgets/my_text_field.dart
View file @
c45e99d
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:one_poem/res/resources.dart'
;
...
...
lib/main.dart
View file @
c45e99d
...
...
@@ -59,11 +59,7 @@ Future<void> main() async {
SystemChrome
.
setEnabledSystemUIMode
(
SystemUiMode
.
manual
,
overlays:
[
SystemUiOverlay
.
bottom
]);
// TODO(weilu): 启动体验不佳。状态栏、导航栏在冷启动开始的一瞬间为黑色,且无法通过隐藏、修改颜色等方式进行处理。。。
// 相关问题跟踪:https://github.com/flutter/flutter/issues/73351
}
class
MyApp
extends
StatelessWidget
{
MyApp
({
Key
?
key
,
this
.
home
,
this
.
theme
})
:
super
(
key:
key
)
{
// 相关问题跟踪:https://github.com/flukey: key) {
Log
.
init
();
initDio
();
Routes
.
initRoutes
();
...
...
lib/tiktok/controller/tiktok_video_list_controller.dart
View file @
c45e99d
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:one_poem/tiktok/mock/video.dart'
;
import
'package:video_player/video_player.dart'
;
...
...
@@ -44,25 +45,33 @@ class TikTokVideoListController extends ChangeNotifier {
// playerOfIndex(oldIndex)?.controller.addListener(_didUpdateValue);
// playerOfIndex(oldIndex)?.showPauseIcon.addListener(_didUpdateValue);
playerOfIndex
(
oldIndex
)?.
pause
();
print
(
'暂停
$oldIndex
'
);
if
(
kDebugMode
)
{
print
(
'暂停
$oldIndex
'
);
}
}
// 开始播放当前的视频
playerOfIndex
(
newIndex
)?.
controller
.
addListener
(
_didUpdateValue
);
playerOfIndex
(
newIndex
)?.
showPauseIcon
.
addListener
(
_didUpdateValue
);
playerOfIndex
(
newIndex
)?.
play
();
print
(
'播放
$newIndex
'
);
if
(
kDebugMode
)
{
print
(
'播放
$newIndex
'
);
}
// 处理预加载/释放内存
for
(
var
i
=
0
;
i
<
playerList
.
length
;
i
++)
{
// 需要释放[disposeCount]之前的视频
if
(
i
<
newIndex
-
disposeCount
||
i
>
newIndex
+
disposeCount
)
{
print
(
'释放
$i
'
);
if
(
kDebugMode
)
{
print
(
'释放
$i
'
);
}
playerOfIndex
(
i
)?.
controller
.
removeListener
(
_didUpdateValue
);
playerOfIndex
(
i
)?.
showPauseIcon
.
removeListener
(
_didUpdateValue
);
playerOfIndex
(
i
)?.
dispose
();
}
else
{
// 需要预加载
if
(
i
>
newIndex
&&
i
<
newIndex
+
preloadCount
)
{
print
(
'预加载
$i
'
);
if
(
kDebugMode
)
{
print
(
'预加载
$i
'
);
}
playerOfIndex
(
i
)?.
init
();
}
}
...
...
@@ -124,6 +133,7 @@ class TikTokVideoListController extends ChangeNotifier {
VPVideoController
get
currentPlayer
=>
playerList
[
index
.
value
];
/// 销毁全部
@override
void
dispose
()
{
// 销毁全部
for
(
var
player
in
playerList
)
{
...
...
@@ -156,12 +166,12 @@ abstract class TikTokVideoController<T> {
Future
<
void
>
play
();
/// 暂停
Future
<
void
>
pause
({
bool
showPauseIcon
:
false
});
Future
<
void
>
pause
({
bool
showPauseIcon
=
false
});
}
class
VPVideoController
extends
TikTokVideoController
<
VideoPlayerController
>
{
VideoPlayerController
?
_controller
;
ValueNotifier
<
bool
>
_showPauseIcon
=
ValueNotifier
<
bool
>(
false
);
final
ValueNotifier
<
bool
>
_showPauseIcon
=
ValueNotifier
<
bool
>(
false
);
final
UserVideo
?
videoInfo
;
...
...
@@ -171,19 +181,17 @@ class VPVideoController extends TikTokVideoController<VideoPlayerController> {
this
.
videoInfo
,
required
ControllerBuilder
<
VideoPlayerController
>
builder
,
ControllerSetter
<
VideoPlayerController
>?
afterInit
,
})
:
this
.
_builder
=
builder
,
this
.
_afterInit
=
afterInit
;
})
:
_builder
=
builder
,
_afterInit
=
afterInit
;
@override
VideoPlayerController
get
controller
{
if
(
_controller
==
null
)
{
_controller
=
_builder
.
call
();
}
_controller
??=
_builder
.
call
();
return
_controller
!;
}
/// 阻止在init的时候dispose,或者在dispose前init
List
<
Future
>
_actLocks
=
[];
final
List
<
Future
>
_actLocks
=
[];
bool
get
isDispose
=>
_disposeLock
!=
null
;
bool
get
prepared
=>
_prepared
;
...
...
@@ -199,7 +207,7 @@ class VPVideoController extends TikTokVideoController<VideoPlayerController> {
var
completer
=
Completer
<
void
>();
_actLocks
.
add
(
completer
.
future
);
_prepared
=
false
;
await
this
.
controller
.
dispose
();
await
controller
.
dispose
();
_controller
=
null
;
_disposeLock
=
Completer
<
void
>();
completer
.
complete
();
...
...
@@ -214,10 +222,10 @@ class VPVideoController extends TikTokVideoController<VideoPlayerController> {
_actLocks
.
clear
();
var
completer
=
Completer
<
void
>();
_actLocks
.
add
(
completer
.
future
);
await
this
.
controller
.
initialize
();
await
this
.
controller
.
setLooping
(
true
);
afterInit
??=
this
.
_afterInit
;
await
afterInit
?.
call
(
this
.
controller
);
await
controller
.
initialize
();
await
controller
.
setLooping
(
true
);
afterInit
??=
_afterInit
;
await
afterInit
?.
call
(
controller
);
_prepared
=
true
;
completer
.
complete
();
if
(
_disposeLock
!=
null
)
{
...
...
@@ -227,7 +235,7 @@ class VPVideoController extends TikTokVideoController<VideoPlayerController> {
}
@override
Future
<
void
>
pause
({
bool
showPauseIcon
:
false
})
async
{
Future
<
void
>
pause
({
bool
showPauseIcon
=
false
})
async
{
await
Future
.
wait
(
_actLocks
);
_actLocks
.
clear
();
await
init
();
...
...
@@ -235,7 +243,7 @@ class VPVideoController extends TikTokVideoController<VideoPlayerController> {
if
(
_disposeLock
!=
null
)
{
await
_disposeLock
?.
future
;
}
await
this
.
controller
.
pause
();
await
controller
.
pause
();
_showPauseIcon
.
value
=
true
;
}
...
...
@@ -248,7 +256,7 @@ class VPVideoController extends TikTokVideoController<VideoPlayerController> {
if
(
_disposeLock
!=
null
)
{
await
_disposeLock
?.
future
;
}
await
this
.
controller
.
play
();
await
controller
.
play
();
_showPauseIcon
.
value
=
false
;
}
...
...
pubspec.lock
View file @
c45e99d
This diff is collapsed. Click to expand it.
Please
register
or
login
to post a comment