我正在尝试使用 Flutter 和 Dart 创建一个狗照片/视频生成器应用程序。它基本上向一个名为random.Dog的网站发送一个获取请求,以获取一个显示在我的应用程序上的 url。有时 url 是视频,有时是 img。当它是视频时,我的应用程序只是缓冲,并且此控制台消息不断出现:
E/flutter ( 4345): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception:
MissingPluginException(No implementation found for method init on channel better_player_channel)
E/flutter ( 4345): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:7)
E/flutter ( 4345): <asynchronous suspension>
E/flutter ( 4345):
E/flutter ( 4345): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method create on channel better_player_channel)
E/flutter ( 4345): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:7)
E/flutter ( 4345): <asynchronous suspension>
E/flutter ( 4345): #1 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:358:43)
E/flutter ( 4345): <asynchronous suspension>
E/flutter ( 4345): #2 MethodChannelVideoPlayer.create (package:better_player/src/video_player/method_channel_video_player.dart:38:9)
E/flutter ( 4345): <asynchronous suspension>
E/flutter ( 4345): #3 VideoPlayerController._create (package:better_player/src/video_player/video_player.dart:202:18)
E/flutter ( 4345): <asynchronous suspension>
E/flutter ( 4345):
I/flutter ( 4345): {"fileSizeBytes":3294982,"url":"https://random.dog/a922da9a-437c-4400-9d94-f36ec2e5452c.mp4"}
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:1D-Input.Impl[N]] codec released a buffer owned by client (index 2)
D/BufferPoolAccessor2.0( 4345): bufferpool2 0xeac5e4a8 : 5(40960 size) total buffers - 5(40960 size) used buffers - 1/7 (recycle/alloc) - 6/45600 (fetch/transfer)
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:1D-Input.Impl[N]] codec released a buffer owned by client (index 0)
I/CCodecConfig( 4345): query failed after returning 19 values (BAD_INDEX)
D/CCodecConfig( 4345): c2 config diff is c2::i32 coding.drc.compression-mode.value = 3
W/Codec2Client( 4345): query -- param skipped: index = 1342179345.
W/Codec2Client( 4345): query -- param skipped: index = 2415921170.
W/Codec2Client( 4345): query -- param skipped: index = 1610614798.
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:Output[N]] popFromStashAndRegister: output format changed to AMessage(what = 0x00000000) = {
D/CCodecBuffers( 4345): int32_t aac-drc-album-mode = 0
D/CCodecBuffers( 4345): int32_t aac-drc-boost-level = 127
D/CCodecBuffers( 4345): int32_t aac-drc-cut-level = 127
D/CCodecBuffers( 4345): int32_t aac-drc-effect-type = 3
D/CCodecBuffers( 4345): int32_t aac-drc-heavy-compression = 3
D/CCodecBuffers( 4345): int32_t aac-drc-output-loudness = -1
D/CCodecBuffers( 4345): int32_t aac-encoded-target-level = -1
D/CCodecBuffers( 4345): int32_t aac-max-output-channel_count = 8
D/CCodecBuffers( 4345): int32_t aac-target-ref-level = 64
D/CCodecBuffers( 4345): int32_t channel-count = 1
D/CCodecBuffers( 4345): string mime = "audio/raw"
D/CCodecBuffers( 4345): int32_t sample-rate = 44100
D/CCodecBuffers( 4345): }
D/CCodecConfig( 4345): c2 config diff is c2::i32 coding.drc.compression-mode.value = 1
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:Output[N]] popFromStashAndRegister: output format changed to AMessage(what = 0x00000000) = {
D/CCodecBuffers( 4345): int32_t aac-drc-album-mode = 0
D/CCodecBuffers( 4345): int32_t aac-drc-boost-level = 127
D/CCodecBuffers( 4345): int32_t aac-drc-cut-level = 127
D/CCodecBuffers( 4345): int32_t aac-drc-effect-type = 3
D/CCodecBuffers( 4345): int32_t aac-drc-heavy-compression = 1
D/CCodecBuffers( 4345): int32_t aac-drc-output-loudness = -1
D/CCodecBuffers( 4345): int32_t aac-encoded-target-level = -1
D/CCodecBuffers( 4345): int32_t aac-max-output-channel_count = 8
D/CCodecBuffers( 4345): int32_t aac-target-ref-level = 64
D/CCodecBuffers( 4345): int32_t channel-count = 1
D/CCodecBuffers( 4345): string mime = "audio/raw"
D/CCodecBuffers( 4345): int32_t sample-rate = 44100
D/CCodecBuffers( 4345): }
D/BufferPoolAccessor2.0( 4345): bufferpool2 0xeac5e4a8 : 5(40960 size) total buffers - 5(40960 size) used buffers - 1/7 (recycle/alloc) - 6/45824 (fetch/transfer)
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:1D-Input.Impl[N]] codec released a buffer owned by client (index 1)
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:1D-Input.Impl[N]] codec released a buffer owned by client (index 0)
I/chatty ( 4345): uid=10154(com.example.randomdog) HwBinder:4345_1 identical 4 lines
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:1D-Input.Impl[N]] codec released a buffer owned by client (index 0)
D/BufferPoolAccessor2.0( 4345): bufferpool2 0xeac5e4a8 : 5(40960 size) total buffers - 5(40960 size) used buffers - 1/7 (recycle/alloc) - 6/46039 (fetch/transfer)
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:1D-Input.Impl[N]] codec released a buffer owned by client (index 3)
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:1D-Input.Impl[N]] codec released a buffer owned by client (index 4)
D/BufferPoolAccessor2.0( 4345): bufferpool2 0xeac5e4a8 : 5(40960 size) total buffers - 5(40960 size) used buffers - 1/7 (recycle/alloc) - 6/46268 (fetch/transfer)
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:1D-Input.Impl[N]] codec released a buffer owned by client (index 2)
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:1D-Input.Impl[N]] codec released a buffer owned by client (index 0)
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:1D-Input.Impl[N]] codec released a buffer owned by client (index 1)
D/BufferPoolAccessor2.0( 4345): bufferpool2 0xeac5e4a8 : 5(40960 size) total buffers - 5(40960 size) used buffers - 1/7 (recycle/alloc) - 6/46498 (fetch/transfer)
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:1D-Input.Impl[N]] codec released a buffer owned by client (index 3)
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:1D-Input.Impl[N]] codec released a buffer owned by client (index 0)
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:1D-Input.Impl[N]] codec released a buffer owned by client (index 4)
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:1D-Input.Impl[N]] codec released a buffer owned by client (index 0)
I/CCodecConfig( 4345): query failed after returning 19 values (BAD_INDEX)
D/CCodecConfig( 4345): c2 config diff is c2::i32 coding.drc.compression-mode.value = 3
W/Codec2Client( 4345): query -- param skipped: index = 1342179345.
W/Codec2Client( 4345): query -- param skipped: index = 2415921170.
W/Codec2Client( 4345): query -- param skipped: index = 1610614798.
D/CCodecBuffers( 4345): [c2.android.aac.decoder#768:Output[N]] popFromStashAndRegister: output format changed to AMessage(what = 0x00000000) = {
而且我的视频不会出现在我的模拟器上。似乎是什么问题,我该如何解决?我的最小代码:
import 'package:better_player/better_player.dart';
void main() => runApp(MaterialApp(home: RandomDog()));
class RandomDog extends StatefulWidget {
@override
_RandomDogState createState() => _RandomDogState();
}
class _RandomDogState extends State<RandomDog> {
var headers = {'Content-Type': 'application/json'};
var body = {};
var video = false;
var img = false;
var message;
var loading = true;
var _controller;
@override
void initState() {
getDog();
super.initState();
}
getDog() async {
loading=true;
var response = await http.get(Uri.https('random.dog', '/woof.json'));
print(response.body);
message = jsonDecode(response.body);
if (message['url'].contains('gif') || message['url'].contains('png') ||
message['url'].contains('jpg') || message['url'].contains('jpeg')) {
video = false;
img = true;
} else {
video = true;
img = false;
}
loading = false;
setState(() {
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
. . .
body: Center(
child: loading == true ? CircularProgressIndicator() : Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Visibility(visible: img,
child: Image.network(message['url'], fit: BoxFit.scaleDown,)),
// Visibility(visible: video,child: VideoApp(url:message['url'])),
video == true? CircularProgressIndicator() :
Visibility(visible: video, child: BetterPlayer.network(message['url'],betterPlayerConfiguration: BetterPlayerConfiguration(autoPlay: true),)), //Chewie(controller: _controller,)
OutlinedButton(onPressed: () async {
getDog();
}, child: Text('GENERATE')),
],
),
),
);
}
}