Reputation: 1
I have a startRecording
function which uses flutter_vlc_player
package. The function will start recording the video displayed in the VLC player.
Future\<void\> startRecording() async {
bool recordingStarted = false;
final directory = await getApplicationDocumentsDirectory();
setState(() {
recording = true;
// final timestamp = DateTime.now().millisecondsSinceEpoch;
saveDirectory = '${directory.path}/recordings/';
logger.i('saveDirectory: $saveDirectory');
});
final saveDir = Directory(saveDirectory);
await saveDir.create();
final result = await _vlcViewController.startRecording(
saveDirectory,
);
recordingStarted = result ?? false;
if (recordingStarted) {
logger.i('Recording started: $recordingStarted');
} else {
logger.w('Recording have not started');
}
}
and in my stopRecording,
Future\<void\> stopRecording() async {
setState(() {
recording = false;
});
final recordingStopped = await \_vlcViewController.stopRecording();
print("recordingStopped $recordingStopped");
if (recordingStopped != null && recordingStopped) {
final recordedPath = await \_vlcViewController.value.recordPath;
logger.i('Recording stopped: $recordingStopped');
final saveDirectoryFileExists = await File(recordedPath).exists();
logger.i("saveDirectoryFileExists: $saveDirectoryFileExists");
final futures = await Future.wait([
File(saveDirectory).exists(),
File("/storage/emulated/0/$saveDirectory").exists(),
File("/sdcard/$saveDirectory").exists(),
]);
print("saveDirectory $saveDirectory");
for (var element in futures) {
logger.i("element: $element");
}
} else {
logger.w('Recording have not stopped');
}
}
@override
void initState() {
super.initState();
\_vlcViewController = VlcPlayerController.network(
stockSourceUrl, // droneSourceUrl,
autoPlay: true,
autoInitialize: true,
hwAcc: HwAcc.full,
options: VlcPlayerOptions(),
);
I tried using the flutter_vlc_player package for recording a live video stream. In my startRecording
, I initialize first the saveDirectory
string path using getApplicationDocumentsDirectory()
function. Then, inside the path, I created the recordings folder where _vlcViewController.startRecording()
should saved the random file after recording. But when I checked the directory in my device, the recording folder is empty which means that it did not save the file. I also tried printing the result
variable and it prints true. To further test, in my stopRecording
, I tried to print the recorded video using _vlcViewController.value.recordPath()
but it prints empty. Do you have an idea why the _vlcViewController.startRecording()
was not able to create the file? Furthermore, I tried to use the _vlcViewController.takeSnapshot()
and printed the result and it prints the frame value.
Upvotes: 0
Views: 54