Open BrianTum opened 3 years ago
How should I also update the HLS playlist URLs when I store files as follows in the stories folder in videos folder? as shown below
Future<String> _uploadFile(filePath, folderName) async {
final file = new File(filePath);
final basename = p.basename(filePath);
String videoUrl;
final Reference ref = FirebaseStorage.instance
.ref()
.child('Stories')
.child('/Videos')
.child(folderName)
.child(basename);
UploadTask uploadTask = ref.putFile(file);
uploadTask.snapshotEvents.listen((TaskSnapshot snapshot) {
final double progress = snapshot.bytesTransferred / snapshot.totalBytes;
setState(() {
_progress = progress;
});
});
The code to update playlist URLs as follows
void _updatePlaylistUrls(File file, String videoName) {
final lines = file.readAsLinesSync();
List<String> updatedLines = [];
for (final String line in lines) {
var updatedLine = line;
if (line.contains('.ts') || line.contains('.m3u8')) {
updatedLine = '$videoName%2F$line?alt=media';
}
updatedLines.add(updatedLine);
}
final updatedContents =
updatedLines.reduce((value, element) => value + '\n' + element);
file.writeAsStringSync(updatedContents);
}
Here is a screenshot of my Firestore file storage
Hi @BrianTum , As for the first issue, you're getting a 404 error from exoplayer:
E/ExoPlayerImplInternal(27998): Caused by: com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 404
Trying to go to the link for your video, you get a 404 from the browser, so the url is broken: https://firebasestorage.googleapis.com/v0/b/picmoni-6e741.appspot.com/o/Stories%2FVideos%2F5cc5ff96-223b-4e9a-8308-cd98fac98830%2Fmaster.m3u8?alt=media&token=1fd5da08-f374-4909-84fd-cea93b056fe0
To check what the correct url should be, you can get the download link of the file from firebase console, then compare it to your url.
Thank you @syonip for your feedback. I found the solution. Problem was on updating the HLS files. I store the file in Subdolders in Firebase Storage i.e. inside videos in stories folders and so I had to rename my HLS files to fetch from these folders i.e.
updatedLine = 'Stories%2FVideos%2F$videoName%2F$line?alt=media';
It's still slow in fetching the videos... Any idea of how to improve video performance?
The performance is a combination of many factors, so I would try to isolate the problem by performing tests:
These test can help you figure out where the problem is.
Hey @syonip and @BrianTum , maybe you can help me figure out what's wrong with my project. My files either are not accessible, or are malformed.
I can access them freely, though, and paths seem to be right, so I can't pinpoint the issue...
Here is a screenshot of the bucket
Here is the link to the master file
Hey I'm trying to fetch for an HLS (.m3u8) video from Firebase Firestore with the following URL sample https://firebasestorage.googleapis.com/v0/b/picmoni-6e741.appspot.com/o/Stories%2FVideos%2F5cc5ff96-223b-4e9a-8308-cd98fac98830%2Fmaster.m3u8?alt=media&token=1fd5da08-f374-4909-84fd-cea93b056fe0
I use the flutters video player to get and play the video as follows
Here is the error I get from the debug console:
Here is the flutter doctor - v
And here is a minimal reproducible code of the error with flutter run -v
Your help will be highly appreciated