Skip to content

Instantly share code, notes, and snippets.

@sbis04
Created February 17, 2021 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbis04/43f1ce5f6703f52a57cc163ea0748859 to your computer and use it in GitHub Desktop.
Save sbis04/43f1ce5f6703f52a57cc163ea0748859 to your computer and use it in GitHub Desktop.
Future<VideoData> storeVideo({String videoUrl}) async {
Response response;
try {
response = await _dio.post(
"/assets",
data: {
"videoUrl": videoUrl,
},
);
} catch (e) {
print('Error starting build: $e');
throw Exception('Failed to store video on MUX');
}
if (response.statusCode == 200) {
VideoData videoData = VideoData.fromJson(response.data);
String status = videoData.data.status;
while (status == 'preparing') {
print('processing...');
await Future.delayed(Duration(seconds: 1));
videoData = await checkPostStatus(videoId: videoData.data.id);
status = videoData.data.status;
}
return videoData;
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment