requestMediaSession method
Implementation
@override
Future<PlaybackUrl> requestMediaSession(
RequestMediaSessionFormData formData,
) async {
try {
final response = await _dio.post(
_requestMediaSession,
data: formData.toJson(),
);
if (response.data != null) {
return PlaybackUrl.fromJson(response.data);
} else {
if (kDebugMode) {
debugPrint("[MAYYA CORE ERROR ON RESPONSE]");
debugPrint("[MAYYA CORE ERROR ON REQUEST MEDIA SESSION]");
}
throw CoreExceptions(
statusCode: CoreExceptions.emptyResponse,
description: 'request media session error occurred empty response',
);
}
} on DioException catch (ex) {
if (kDebugMode) {
debugPrint("[MAYYA CORE DIO ERROR]");
debugPrint("[MAYYA CORE ERROR ON REQUEST MEDIA SESSION]");
}
switch (ex.type) {
case DioExceptionType.connectionTimeout:
throw CoreExceptions(
statusCode: CoreExceptions.connectionTimeout,
description: "connectionTimeout",
stackTrace: ex.stackTrace,
);
case DioExceptionType.sendTimeout:
throw CoreExceptions(
statusCode: CoreExceptions.sendTimeout,
description: "sendTimeout",
stackTrace: ex.stackTrace,
);
case DioExceptionType.receiveTimeout:
throw CoreExceptions(
statusCode: CoreExceptions.receiveTimeout,
description: "receiveTimeout",
stackTrace: ex.stackTrace,
);
case DioExceptionType.badCertificate:
throw CoreExceptions(
statusCode: CoreExceptions.badCertificate,
description: "badCertificate",
stackTrace: ex.stackTrace,
);
case DioExceptionType.badResponse:
throw _handleBadResponse(ex);
case DioExceptionType.cancel:
throw CoreExceptions(
statusCode: CoreExceptions.cancel,
description: "cancel",
stackTrace: ex.stackTrace,
);
case DioExceptionType.connectionError:
throw CoreExceptions(
statusCode: CoreExceptions.connectionError,
description: "connectionError",
stackTrace: ex.stackTrace,
);
case DioExceptionType.unknown:
throw CoreExceptions(
statusCode: CoreExceptions.unknown,
description: "unknown",
stackTrace: ex.stackTrace,
);
}
} catch (e) {
if (kDebugMode) {
debugPrint("[MAYYA CORE ERROR]");
debugPrint("[MAYYA CORE ERROR ON REQUEST MEDIA SESSION]");
}
throw CoreExceptions(
statusCode: CoreExceptions.implementationError,
description: "ERROR ON REQUEST MEDIA SESSION",
);
}
}