Permission to read External Storage is Granted. I am trying to read the path of files in a folder and if the path contains ".mp4" then make an image thumbnail from the video.
_mediaList the list of paths of all the files in the folder.
sample-path is like storage/emulated/0/StatusSaver/Downloads/469a14c6f26e47968b322b9d08ebe2b0.mp4
_mediaList.forEach((element) async {
if (element.path.contains(".mp4")) {
print("Video Status");
await VideoThumbnail.thumbnailData(
video: element.path,
imageFormat: ImageFormat.JPEG,
maxWidth:
128,
quality: 25,
).then((value) {
StatusList.insert(0, {
"type": StatusType.video,
"path": element.path,
"thumbnail": value
});
});
}
Error is like this
I/flutter (18331): PermissionStatus.granted
D/ThumbnailPlugin(18331): buildThumbnailData( format:0, maxh:0, maxw:128, timeMs:0, quality:25 )
W/System.err(18331): java.lang.RuntimeException: setDataSource failed: status = 0xFFFFFFEA
W/System.err(18331): at android.media.MediaMetadataRetriever._setDataSource(Native Method)
W/System.err(18331): at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:103)
W/System.err(18331): at xyz.justsoft.video_thumbnail.VideoThumbnailPlugin.createVideoThumbnail(VideoThumbnailPlugin.java:205)
W/System.err(18331): at xyz.justsoft.video_thumbnail.VideoThumbnailPlugin.buildThumbnailData(VideoThumbnailPlugin.java:116)
W/System.err(18331): at xyz.justsoft.video_thumbnail.VideoThumbnailPlugin.access$100(VideoThumbnailPlugin.java:37)
W/System.err(18331): at xyz.justsoft.video_thumbnail.VideoThumbnailPlugin$1.run(VideoThumbnailPlugin.java:77)
W/System.err(18331): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err(18331): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err(18331): at java.lang.Thread.run(Thread.java:919)
E/flutter (18331): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method data on channel video_thumbnail)
E/flutter (18331): #0 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:156
E/flutter (18331): <asynchronous suspension>
E/flutter (18331): #1 VideoThumbnail.thumbnailData
package:video_thumbnail/video_thumbnail.dart:67
E/flutter (18331): <asynchronous suspension>
E/flutter (18331): #2 FileUtils.readSavedStatusFolder.<anonymous closure>
package:statussaver/model/file_utils.dart:53
E/flutter (18331): <asynchronous suspension>
E/flutter (18331):
So, The issue was with the path going into the thumbnailData.
I just had to add a "/" at the starting of the path.
As without "/", it was able to read the videos.
Related
I have this code below which plays a sound every time I hit a button.
AudioPlayer player = AudioPlayer();
Future<void> playSound({required String soundStr}) async {
player.setAsset(soundStr);
player.play();
}
But whenever I hit the button fast, sometimes it will show this error. How can I eliminate this error? I tried adding player.stop(); but it still the same.
E/flutter ( 4312): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(abort, Loading interrupted, null, null)
E/flutter ( 4312): #0 AudioPlayer._setPlatformActive.checkInterruption (package:just_audio/just_audio.dart:1236:7)
E/flutter ( 4312): #1 AudioPlayer._setPlatformActive.setPlatform (package:just_audio/just_audio.dart:1347:11)
E/flutter ( 4312): <asynchronous suspension>
E/flutter ( 4312):
E/flutter ( 4312): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(abort, Loading interrupted, null, null)
E/flutter ( 4312):
Edit: I tried adding await.
Future<void> playSound({required String soundStr}) async {
await player.setAsset(soundStr);
await player.play();
}
If I hit the buttons fast, it will still have error. Though it is now different.
E/flutter (21654): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Connection aborted
E/flutter (21654): #0 AudioPlayer._load (package:just_audio/just_audio.dart:843:11)
E/flutter (21654): <asynchronous suspension>
E/flutter (21654): #1 AudioPlayer.load (package:just_audio/just_audio.dart:770:14)
E/flutter (21654): <asynchronous suspension>
E/flutter (21654): #2 AudioPlayer.setAudioSource (package:just_audio/just_audio.dart:745:18)
E/flutter (21654): <asynchronous suspension>
E/flutter (21654): #3 playSound (package:super_pinoy_quiz/common/generic_methods.dart:396:3)
E/flutter (21654): <asynchronous suspension>
E/flutter (21654):
I'm using this package: just_audio: ^0.9.29
Though I tried using different package but it also encounters the same error when hitting the button fast: audioplayers: ^1.1.1
Both setAsset and play are future method, you can await for setting assets
Future<void> playSound({required String soundStr}) async {
await player.setAsset(soundStr);
await player.play();
}
I am using just_audio package to play my base64 string which is a wav file that I received from my server. The app is being played from an android device API 30-ish. This is the error once the base64 is loaded:
E/flutter (31770): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method disposeAllPlayers on channel com.ryanheise.just_audio.methods)
E/flutter (31770): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165:7)
E/flutter (31770): <asynchronous suspension>
E/flutter (31770): #1 MethodChannelJustAudio.disposeAllPlayers (package:just_audio_platform_interface/method_channel_just_audio.dart:29:10)
E/flutter (31770): <asynchronous suspension>
E/flutter (31770):
E/flutter (31770): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method init on channel com.ryanheise.just_audio.methods)
E/flutter (31770): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165:7)
E/flutter (31770): <asynchronous suspension>
E/flutter (31770): #1 MethodChannelJustAudio.init (package:just_audio_platform_interface/method_channel_just_audio.dart:13:5)
E/flutter (31770): <asynchronous suspension>
E/flutter (31770): #2 AudioPlayer._setPlatformActive.setPlatform (package:just_audio/just_audio.dart:1330:13)
E/flutter (31770): <asynchronous suspension>
E/flutter (31770):
My custom base64 player which I follow from the instruction of the page:
class MyAudioPlayer extends StreamAudioSource {
MyAudioPlayer({this.bytes});
List<int> bytes;
#override
Future<StreamAudioResponse> request([int start, int end]) async {
final start = 0;
final end = bytes.length;
return StreamAudioResponse(
sourceLength: bytes.length,
contentLength: end - start,
offset: start,
stream: Stream.value(bytes.sublist(start, end)),
contentType: "audio/x-wav",
);
}
}
The file in which I played:
void playTTS(String content) async{
Dialogs.showLoadingDialog(context: context);
final List<int> base64 = await ApiService.textToSpeech(content);
final player = AudioPlayer();
await player.setAudioSource(MyAudioPlayer(bytes: base64));
await player.play();
Navigator.of(context, rootNavigator: true).pop();
listString.value = List.from(listString.value..add(ValueNotifier(content)));
}
I have set already set this to my androidmanifest.xml to true already.
android:usesCleartextTraffic="true"
Any help is appreciated.
Seems like I don't have to convert the base64 Wav file with a custom class like the tutorial did. According to the online converter, all I have to do was put data:audio/wav;base64,$base64 before the actual base64 string and uses the normal setUrl and it worked:
final String code = "data:audio/wav;base64," + json.decode(response.body)["base64"];
final player = AudioPlayer();
player.setUrl(code);
await player.play();
i already initialized awesome_notifications plugin in main.dart When i hot restart, in debug console i'm getting this error:
E/flutter ( 4447): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method initialize on channel awesome_notifications)
E/flutter ( 4447): #0 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:165
E/flutter ( 4447): <asynchronous suspension>
E/flutter ( 4447): #1 AwesomeNotifications.initialize (package:awesome_notifications/src/awesome_notifications_core.dart:174:18)
E/flutter ( 4447): <asynchronous suspension>
E/flutter ( 4447):
E/flutter ( 4447): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method isNotificationAllowed on channel awesome_notifications)
E/flutter ( 4447): #0 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:165
E/flutter ( 4447): <asynchronous suspension>
Here's my code :
main.dart
Future<void> main() async {
WidgetsFlutterBinding();
await Hive.initFlutter();
if (!Hive.isAdapterRegistered(AddEventModelAdapter().typeId)) {
Hive.registerAdapter(AddEventModelAdapter());
}
AwesomeNotifications()
.initialize('resource://drawable/res_notification_app_icon', [
NotificationChannel(
channelKey: 'schedule_channel',
channelName: 'scheduled_channel',
channelDescription: 'descroiption',
locked: true,
importance: NotificationImportance.High,
),
]);
runApp(const MyApp());
}
Whenever you add a plugin in your pubspec.yaml, you need to stop the app and re-run it again because the plugin contains native code on both platforms.
If it still does not work, then do flutter clean and run.
TFLite (movenet/multipose/lightning/tflite/float16)
I have loaded the model successfully but whenever I tried to run it... it just crashes the
app.
here is the code for loading and running the model:
Future loadModel() async {
try {
res = await Tflite.loadModel(
model:
"assets/lite-model_movenet_multipose_lightning_tflite_float16_1.tflite",
);
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> model loaded: " + res.toString());
} catch (e) {
print(e);
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Failed to load model.');
} }
Future poseNet(File image) async {
int startTime = new DateTime.now().millisecondsSinceEpoch;
var output = await Tflite.runPoseNetOnImage(
threshold: 0.7,
path: image.path,
numResults: 5,
nmsRadius: 15
);
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> recognitions: ${output}');
setState(() {
_recognitions = output!;
});
int endTime = new DateTime.now().millisecondsSinceEpoch;
print(
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Inference took ${endTime - startTime}ms ");}
here are the logs:
I/tflite (11904): Initialized TensorFlow Lite runtime.
I/flutter (11904): >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> model loaded: success
W/System (11904): A resource failed to call close.
D/EGL_emulation(11904): eglCreateContext: 0xead612c0: maj 2 min 0 rcv 2
E/flutter (11904): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(Failed to run model, length=3; index=3, java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
E/flutter (11904): at sq.flutter.tflite.TflitePlugin.initPoseNet(TflitePlugin.java:1262)
E/flutter (11904): at sq.flutter.tflite.TflitePlugin$RunPoseNet.<init>(TflitePlugin.java:1290)
E/flutter (11904): at sq.flutter.tflite.TflitePlugin.runPoseNetOnImage(TflitePlugin.java:1217)
E/flutter (11904): at sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:179)
E/flutter (11904): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/flutter (11904): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:178)
E/flutter (11904): at io.flutter.embedding.engine.dart.DartMessenger.lambda$handleMessageFromDart$0$DartMessenger(DartMessenger.java:206)
E/flutter (11904): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$6ZD1MYkhaLxyPjtoFDxe45u43DI.run(Unknown Source:12)
E/flutter (11904): at android.os.Handler.handleCallback(Handler.java:938)
E/flutter (11904): at android.os.Handler.dispatchMessage(Handler.java:99)
E/flutter (11904): at android.os.Looper.loop(Looper.java:223)
E/flutter (11904): at android.app.ActivityThread.main(ActivityThread.java:7656)
E/flutter (11904): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (11904): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/flutter (11904): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/flutter (11904): , null)
E/flutter (11904): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter (11904): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter (11904): <asynchronous suspension>
E/flutter (11904): #2 Tflite.runPoseNetOnImage (package:tflite/tflite.dart:350:12)
E/flutter (11904): <asynchronous suspension>
E/flutter (11904): #3 _SelectImageState.poseNet (package:model_ui/main/select_image.dart:105:18)
E/flutter (11904): <asynchronous suspension>
E/flutter (11904):
any help will be appreciated!
thank you!
I'm not an expert. But tflite plugin is out of date. You should try your luck with the tflite_flutter, which is also a bit outdated. But worked for me.
I am trying to implement the twilio_voice: ^0.0.9 plug in and register my firebase app at the same time but, when I run my registration function I get the error:
E/flutter (27321): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: [firebase_functions/not-found] NOT_FOUND
E/flutter (27321):
E/flutter (27321): #0 StandardMethodCodec.decodeEnvelope
package:flutter/…/services/message_codecs.dart:607
E/flutter (27321): #1 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:156
E/flutter (27321): <asynchronous suspension>
E/flutter (27321): #2 MethodChannelHttpsCallable.call
package:cloud_functions_platform_interface/…/method_channel/method_channel_https_callable.dart:23
E/flutter (27321): <asynchronous suspension>
E/flutter (27321): #3 HttpsCallable.call
package:cloud_functions/src/https_callable.dart:35
E/flutter (27321): <asynchronous suspension>
E/flutter (27321): #4 _TextScreenState.register
package:buddiesDrivers/CallScreen/TextScreen.dart:72
E/flutter (27321): <asynchronous suspension>
E/flutter (27321):
E/flutter (27321): #0 MethodChannelHttpsCallable.call
package:cloud_functions_platform_interface/…/method_channel/method_channel_https_callable.dart:39
E/flutter (27321): <asynchronous suspension>
E/flutter (27321): #1 HttpsCallable.call
package:cloud_functions/src/https_callable.dart:35
E/flutter (27321): <asynchronous suspension>
I am have firebase implemented and running and I am getting my token when logging in. The app seems to fail when calling the httpsCallable("voice-accessToken") in the app. Here is the function:
register() async {
print("voip-registtering with token ");
print("voip-calling voice-accessToken");
final function =
FirebaseFunctions.instance.httpsCallable("voice-accessToken");
final data = {
"platform": Platform.isIOS ? "iOS" : "Android",
};
final result = await function.call(data);
print("voip-result");
print(result.data);
String androidToken;
if (Platform.isAndroid) {
androidToken = await FirebaseMessaging.instance.getToken();
print("androidToken is " + androidToken);
}
TwilioVoice.instance
.setTokens(accessToken: result.data, deviceToken: androidToken);
}
Any help in the right direction would be appreciated