Closed imsujan276 closed 9 months ago
Hi,
Thanks for reporting the issue.
I guess that the issue is due to a force unwrap of the flutterView
(see https://github.com/apivideo/api.video-flutter-live-stream/blob/c0a17de876343585fccf656eb471598c18e58f36/android/src/main/kotlin/video/api/flutter/livestream/MethodCallHandlerImpl.kt#L100)
For dispose
and stops
methods, this should do nothing if flutterView
is null
I don't know why this happen on your side, when does it crash? Have you call dispose
before?
Thank you @ThibaultBee. That fixed the closed issue.
But I am getting another issue while starting the streaming.
THIS HAPPENS THE FIRST TIME THE STREAMING. LATER THIS ISSUES DOES NOT COME
On page load, I am calling the init()
to initialize the controller. Once initialized, I am starting the streaming.
Am I doing something wrong here?
E/flutter ( 9243): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(failed_to_start_preview, Video has not been configured!, null, null)
E/flutter ( 9243): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7)
E/flutter ( 9243): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:322:18)
E/flutter ( 9243): <asynchronous suspension>
code I am using
init(){
controller = createLiveStreamController();
controller!.initialize().then((_) {
log('VideoStream: Initialized');
startStreaming();
listenToInternetConnection();
}).catchError((e) => showSnackbar(e.toString()));
}
ApiVideoLiveStreamController createLiveStreamController() {
return ApiVideoLiveStreamController(
initialAudioConfig: rtmsConfig.audioConfig,
initialVideoConfig: rtmsConfig.videoConfig,
onConnectionSuccess: () {
log('VideoStream: Connection succeeded');
},
onConnectionFailed: (error) {
log('VideoStream: Connection failed: $error');
},
onDisconnection: () {
log('VideoStream: Connection Disconnected');
},
onError: (err) {
log('VideoStream: Connection Error: $err');
},
);
}
Future<void> startStreaming() async {
try {
setLiveStatus(LiveStatus.loading);
await controller?.startStreaming(
url: rtmsConfig.rtmpUrl,
streamKey: rtmsConfig.rtmpStreamKey,
);
log('VideoStream: Stream Started');
} catch (e) {
log('VideoStream: Failed to start stream: $e');
}
}
Hi, I don't reproduced this behavior on my side. Could you fork this repo and modify the example code to show me how to reproduce?
I am not doing any extra configurations.
just calling the init function in initState and everything is the same.
To reproduce the error,
Ok, it is an issue with the permissions. Could you test: https://github.com/apivideo/api.video-flutter-live-stream/commit/42f8a0e11eb12419fd128daeca56d6f46a9b644f?
Now, I am not able to build the app
Getting this error
flutter run -t lib/main_prod.dart --flavor prod
Launching lib/main_prod.dart on sdk gphone64 x86 64 in debug mode...
e: apivideo_live_stream/android/src/main/kotlin/video/api/flutter/livestream/MethodCallHandlerImpl.kt:73:21 Val cannot be reassigned
e: apivideo_live_stream/android/src/main/kotlin/video/api/flutter/livestream/MethodCallHandlerImpl.kt:83:21 Val cannot be reassigned
e: apivideo_live_stream/android/src/main/kotlin/video/api/flutter/livestream/MethodCallHandlerImpl.kt:92:48 No value passed for parameter 'onSuccess'
e: apivideo_live_stream/android/src/main/kotlin/video/api/flutter/livestream/MethodCallHandlerImpl.kt:92:48 No value passed for parameter 'onError'
e: apivideo_live_stream/android/src/main/kotlin/video/api/flutter/livestream/MethodCallHandlerImpl.kt:156:21 Val cannot be reassigned
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':apivideo_live_stream:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more details
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
Running Gradle task 'assembleProdDebug'... 5.0s
Exception: Gradle task assembleProdDebug failed with exit code 1
Hi,
CI properly runs (see https://github.com/apivideo/api.video-flutter-live-stream/actions/runs/7787509905). Could you clone the project from scratch?
Yes now i am able to run the app.
But getting new error after giving the permission
E/flutter ( 6246): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(failed_to_set_audio_config, Video has not been configured!, null, null)
E/flutter ( 6246): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7)
E/flutter ( 6246): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:322:18)
E/flutter ( 6246): <asynchronous suspension>
E/flutter ( 6246):
This could happens because startPreview
is called directly by didChangeAppLifecycleState
although video configuration have not been applied. Anyway, internally startPreview
will be called after the video configuration is set.
But failed_to_set_audio_config
should be failed_to_start_preview
.
It is just a message and I guess the behavior is correct now.
So, can I leave it as it is?
Will it not cause issues in the future?
To avoid the error to pop, you can do something like when you call startPreview
(ie in didChangeAppLifecycleState
)
if (_controller.isInitialized) {
_controller.startPreview();
}
Alternatively, you might register didChangeAppLifecycleState
when the controller
has been initialized.
But that depends on your implementation.
This issue is solved in v1.2.0. Please reopen it if you feel something is missing.
Version
v1.1.1
Which operating systems have you used?
Environment that reproduces the issue
Google pixel 5 Android 12
Is it reproducible in the example application?
Yes
RTMP Server
api.video
Reproduction steps
Expected result
there should be no errors
Actual result
got the following error
Additional context
No response
Relevant logs output
No response