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 Pun
2022-01-25 11:11:31 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4c84b1aa609772c80498a6f0b6285b11ea64608d
4c84b1aa
1 parent
0d94adfa
清理了视频录制页面按钮(可通过此次提交恢复)
升级了插件版本
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
358 deletions
lib/poem/page/poem_record_video.dart
lib/recorder/video/preview_screen.dart
pubspec.lock
lib/poem/page/poem_record_video.dart
View file @
4c84b1a
...
...
@@ -23,20 +23,10 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
File
?
_imageFile
;
File
?
_videoFile
;
// Initial values
final
bool
_isVideoCameraSelected
=
true
;
bool
_isCameraInitialized
=
false
;
bool
_isRearCameraSelected
=
true
;
bool
_isVideoCameraSelected
=
false
;
bool
_isRecordingInProgress
=
false
;
double
_minAvailableExposureOffset
=
0.0
;
double
_maxAvailableExposureOffset
=
0.0
;
double
_minAvailableZoom
=
1.0
;
double
_maxAvailableZoom
=
1.0
;
// Current values
double
_currentZoomLevel
=
1.0
;
double
_currentExposureOffset
=
0.0
;
FlashMode
?
_currentFlashMode
;
List
<
File
>
allFileList
=
[];
...
...
@@ -193,11 +183,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
}
}
void
resetCameraValues
()
async
{
_currentZoomLevel
=
1.0
;
_currentExposureOffset
=
0.0
;
}
void
onNewCameraSelected
(
CameraDescription
cameraDescription
)
async
{
final
previousCameraController
=
controller
;
...
...
@@ -209,8 +194,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
await
previousCameraController
?.
dispose
();
resetCameraValues
();
if
(
mounted
)
{
setState
(()
{
controller
=
cameraController
;
...
...
@@ -224,22 +207,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
try
{
await
cameraController
.
initialize
();
await
Future
.
wait
([
cameraController
.
getMinExposureOffset
()
.
then
((
value
)
=>
_minAvailableExposureOffset
=
value
),
cameraController
.
getMaxExposureOffset
()
.
then
((
value
)
=>
_maxAvailableExposureOffset
=
value
),
cameraController
.
getMaxZoomLevel
()
.
then
((
value
)
=>
_maxAvailableZoom
=
value
),
cameraController
.
getMinZoomLevel
()
.
then
((
value
)
=>
_minAvailableZoom
=
value
),
]);
_currentFlashMode
=
controller
!.
value
.
flashMode
;
}
on
CameraException
catch
(
e
)
{
// print('Error initializing camera: $e');
}
...
...
@@ -280,11 +247,7 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
child:
Scaffold
(
backgroundColor:
Colors
.
black
,
body:
_isCameraInitialized
?
Column
(
children:
[
AspectRatio
(
aspectRatio:
1
/
controller
!.
value
.
aspectRatio
,
child:
Stack
(
?
Stack
(
children:
[
controller
!.
buildPreview
(),
Padding
(
...
...
@@ -297,140 +260,17 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
end
,
children:
[
Align
(
alignment:
Alignment
.
topRight
,
child:
Container
(
decoration:
BoxDecoration
(
color:
Colors
.
black87
,
borderRadius:
BorderRadius
.
circular
(
10.0
),
),
child:
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
8.0
,
right:
8.0
,
),
child:
DropdownButton
<
ResolutionPreset
>(
dropdownColor:
Colors
.
black87
,
underline:
Container
(),
value:
currentResolutionPreset
,
items:
[
for
(
ResolutionPreset
preset
in
resolutionPresets
)
DropdownMenuItem
(
child:
Text
(
preset
.
toString
()
.
split
(
'.'
)[
1
]
.
toUpperCase
(),
style:
const
TextStyle
(
color:
Colors
.
white
),
),
value:
preset
,
)
],
onChanged:
(
value
)
{
setState
(()
{
currentResolutionPreset
=
value
!;
_isCameraInitialized
=
false
;
});
onNewCameraSelected
(
controller
!.
description
);
},
hint:
const
Text
(
"Select item"
),
),
),
),
),
// Spacer(),
Padding
(
padding:
const
EdgeInsets
.
only
(
right:
8.0
,
top:
16.0
),
child:
Container
(
decoration:
BoxDecoration
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
circular
(
10.0
),
),
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
Text
(
_currentExposureOffset
.
toStringAsFixed
(
1
)
+
'x'
,
style:
const
TextStyle
(
color:
Colors
.
black
),
),
),
),
),
Expanded
(
child:
RotatedBox
(
quarterTurns:
3
,
child:
SizedBox
(
height:
30
,
child:
Slider
(
value:
_currentExposureOffset
,
min:
_minAvailableExposureOffset
,
max:
_maxAvailableExposureOffset
,
activeColor:
Colors
.
white
,
inactiveColor:
Colors
.
white30
,
onChanged:
(
value
)
async
{
setState
(()
{
_currentExposureOffset
=
value
;
});
await
controller
!
.
setExposureOffset
(
value
);
},
),
),
),
),
Row
(
children:
[
Expanded
(
child:
Slider
(
value:
_currentZoomLevel
,
min:
_minAvailableZoom
,
max:
_maxAvailableZoom
,
activeColor:
Colors
.
white
,
inactiveColor:
Colors
.
white30
,
onChanged:
(
value
)
async
{
setState
(()
{
_currentZoomLevel
=
value
;
});
await
controller
!.
setZoomLevel
(
value
);
},
),
),
Padding
(
padding:
const
EdgeInsets
.
only
(
right:
8.0
),
child:
Container
(
decoration:
BoxDecoration
(
color:
Colors
.
black87
,
borderRadius:
BorderRadius
.
circular
(
10.0
),
),
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
Text
(
_currentZoomLevel
.
toStringAsFixed
(
1
)
+
'x'
,
style:
const
TextStyle
(
color:
Colors
.
white
),
),
),
),
),
],
const
Spacer
(
flex:
1
,
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
InkWell
(
onTap:
_isRecordingInProgress
?
()
async
{
if
(
controller
!
.
value
.
isRecordingPaused
)
{
if
(
controller
!.
value
.
isRecordingPaused
)
{
await
resumeVideoRecording
();
}
else
{
await
pauseVideoRecording
();
...
...
@@ -456,8 +296,7 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
size:
60
,
),
_isRecordingInProgress
?
controller
!
.
value
.
isRecordingPaused
?
controller
!.
value
.
isRecordingPaused
?
const
Icon
(
Icons
.
play_arrow
,
color:
Colors
.
white
,
...
...
@@ -479,23 +318,19 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
),
),
InkWell
(
onTap:
_isVideoCameraSelected
?
()
async
{
onTap:
()
async
{
if
(
_isRecordingInProgress
)
{
XFile
?
rawVideo
=
await
stopVideoRecording
();
File
videoFile
=
File
(
rawVideo
!.
path
);
XFile
?
rawVideo
=
await
stopVideoRecording
();
File
videoFile
=
File
(
rawVideo
!.
path
);
int
currentUnix
=
DateTime
.
now
()
.
millisecondsSinceEpoch
;
int
currentUnix
=
DateTime
.
now
()
.
millisecondsSinceEpoch
;
final
directory
=
await
getApplicationDocumentsDirectory
();
String
fileFormat
=
videoFile
.
path
.
split
(
'.'
)
.
last
;
String
fileFormat
=
videoFile
.
path
.
split
(
'.'
).
last
;
_videoFile
=
await
videoFile
.
copy
(
'
${directory.path}
/
$currentUnix
.
$fileFormat
'
,
...
...
@@ -505,26 +340,6 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
}
else
{
await
startVideoRecording
();
}
}
:
()
async
{
XFile
?
rawImage
=
await
takePicture
();
File
imageFile
=
File
(
rawImage
!.
path
);
int
currentUnix
=
DateTime
.
now
()
.
millisecondsSinceEpoch
;
final
directory
=
await
getApplicationDocumentsDirectory
();
String
fileFormat
=
imageFile
.
path
.
split
(
'.'
).
last
;
await
imageFile
.
copy
(
'
${directory.path}
/
$currentUnix
.
$fileFormat
'
,
);
refreshAlreadyCapturedImages
();
},
child:
Stack
(
alignment:
Alignment
.
center
,
...
...
@@ -555,13 +370,11 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
),
),
InkWell
(
onTap:
_imageFile
!=
null
||
_videoFile
!=
null
onTap:
_imageFile
!=
null
||
_videoFile
!=
null
?
()
{
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
(
builder:
(
context
)
=>
PreviewScreen
(
builder:
(
context
)
=>
PreviewScreen
(
imageFile:
_imageFile
!,
fileList:
allFileList
,
),
...
...
@@ -574,8 +387,7 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
height:
60
,
decoration:
BoxDecoration
(
color:
Colors
.
black
,
borderRadius:
BorderRadius
.
circular
(
10.0
),
borderRadius:
BorderRadius
.
circular
(
10.0
),
border:
Border
.
all
(
color:
Colors
.
white
,
width:
2
,
...
...
@@ -588,16 +400,14 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
:
null
,
),
child:
videoController
!=
null
&&
videoController
!
.
value
.
isInitialized
videoController
!.
value
.
isInitialized
?
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
8.0
),
child:
AspectRatio
(
aspectRatio:
videoController
!
.
value
.
aspectRatio
,
child:
VideoPlayer
(
videoController
!),
child:
VideoPlayer
(
videoController
!),
),
)
:
Container
(),
...
...
@@ -609,155 +419,10 @@ class _PoemRecordVideoPageState extends State<PoemRecordVideoPage>
),
),
],
),
),
Expanded
(
child:
SingleChildScrollView
(
physics:
const
BouncingScrollPhysics
(),
child:
Column
(
children:
[
Padding
(
padding:
const
EdgeInsets
.
only
(
top:
8.0
),
child:
Row
(
children:
[
Expanded
(
child:
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
8.0
,
right:
4.0
,
),
child:
TextButton
(
onPressed:
_isRecordingInProgress
?
null
:
()
{
if
(
_isVideoCameraSelected
)
{
setState
(()
{
_isVideoCameraSelected
=
false
;
});
}
},
style:
TextButton
.
styleFrom
(
primary:
_isVideoCameraSelected
?
Colors
.
black54
:
Colors
.
black
,
backgroundColor:
_isVideoCameraSelected
?
Colors
.
white30
:
Colors
.
white
,
),
child:
const
Text
(
'IMAGE'
),
),
),
),
Expanded
(
child:
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
4.0
,
right:
8.0
),
child:
TextButton
(
onPressed:
()
{
if
(!
_isVideoCameraSelected
)
{
setState
(()
{
_isVideoCameraSelected
=
true
;
});
}
},
style:
TextButton
.
styleFrom
(
primary:
_isVideoCameraSelected
?
Colors
.
black
:
Colors
.
black54
,
backgroundColor:
_isVideoCameraSelected
?
Colors
.
white
:
Colors
.
white30
,
),
child:
const
Text
(
'VIDEO'
),
),
),
),
],
),
),
Padding
(
padding:
const
EdgeInsets
.
fromLTRB
(
16.0
,
8.0
,
16.0
,
8.0
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
InkWell
(
onTap:
()
async
{
setState
(()
{
_currentFlashMode
=
FlashMode
.
off
;
});
await
controller
!.
setFlashMode
(
FlashMode
.
off
,
);
},
child:
Icon
(
Icons
.
flash_off
,
color:
_currentFlashMode
==
FlashMode
.
off
?
Colors
.
amber
:
Colors
.
white
,
),
),
InkWell
(
onTap:
()
async
{
setState
(()
{
_currentFlashMode
=
FlashMode
.
auto
;
});
await
controller
!.
setFlashMode
(
FlashMode
.
auto
,
);
},
child:
Icon
(
Icons
.
flash_auto
,
color:
_currentFlashMode
==
FlashMode
.
auto
?
Colors
.
amber
:
Colors
.
white
,
),
),
InkWell
(
onTap:
()
async
{
setState
(()
{
_currentFlashMode
=
FlashMode
.
always
;
});
await
controller
!.
setFlashMode
(
FlashMode
.
always
,
);
},
child:
Icon
(
Icons
.
flash_on
,
color:
_currentFlashMode
==
FlashMode
.
always
?
Colors
.
amber
:
Colors
.
white
,
),
),
InkWell
(
onTap:
()
async
{
setState
(()
{
_currentFlashMode
=
FlashMode
.
torch
;
});
await
controller
!.
setFlashMode
(
FlashMode
.
torch
,
);
},
child:
Icon
(
Icons
.
highlight
,
color:
_currentFlashMode
==
FlashMode
.
torch
?
Colors
.
amber
:
Colors
.
white
,
),
),
],
),
)
],
),
),
),
],
)
:
const
Center
(
child:
Text
(
'
LOADING
'
,
'
开启摄像头..
'
,
style:
TextStyle
(
color:
Colors
.
white
),
),
),
...
...
lib/recorder/video/preview_screen.dart
View file @
4c84b1a
...
...
@@ -32,7 +32,7 @@ class PreviewScreen extends StatelessWidget {
),
);
},
child:
Text
(
'Go to all captures
'
),
child:
const
Text
(
'打开全部视频
'
),
style:
TextButton
.
styleFrom
(
primary:
Colors
.
black
,
backgroundColor:
Colors
.
white
,
...
...
pubspec.lock
View file @
4c84b1a
...
...
@@ -1118,7 +1118,7 @@ packages:
name: url_launcher_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.
2
"
version: "2.0.
3
"
url_launcher_platform_interface:
dependency: transitive
description:
...
...
@@ -1181,7 +1181,7 @@ packages:
name: video_player
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1
3
"
version: "2.2.1
5
"
video_player_platform_interface:
dependency: transitive
description:
...
...
Please
register
or
login
to post a comment