'MissingPluginException(No implementation found for method on init channel better_player_channel)
I am getting the following error even though I copied the example from better_player documentation. I made sure my target on android is 31, kotlin is 1.5+, and internet permission is enabled. Here is my flutter version:
➜ drm_player git:(main) ✗ flutter --version
Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git Framework • revision 77d935af4d (6 weeks ago) • 2021-12-16 08:37:33 -0800 Engine • revision 890a5fca2e Tools • Dart 2.15.1
Here is my code i am struggling with:
import 'package:better_player/better_player.dart';
import 'package:drm_player/constants.dart';
import 'package:flutter/material.dart';
class WidevinePlayer extends StatefulWidget {
const WidevinePlayer({Key? key}) : super(key: key);
@override
_WidevinePlayerState createState() => _WidevinePlayerState();
}
class _WidevinePlayerState extends State<WidevinePlayer> {
late BetterPlayerController _widevineController;
@override
void initState() {
setUpWidvineController();
super.initState();
}
void setUpWidvineController() async {
BetterPlayerConfiguration betterPlayerConfig =
const BetterPlayerConfiguration(aspectRatio: 16 / 9, fit: BoxFit.contain);
_widevineController = BetterPlayerController(betterPlayerConfig);
BetterPlayerDataSource widevineDataSource = BetterPlayerDataSource(
BetterPlayerDataSourceType.network, kWidevineVideoUrl,
drmConfiguration: BetterPlayerDrmConfiguration(
drmType: BetterPlayerDrmType.widevine,
licenseUrl: kLicenseUrl,)
);
_widevineController.setupDataSource(widevineDataSource);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Widevine Player"),
),
body: SingleChildScrollView(
child: Column(
children: [
AspectRatio(
aspectRatio: 16 / 9,
child: BetterPlayer(
controller: _widevineController,
),
),
],
),
),
);
}
}
Here are my errors:
E/flutter ( 9272): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method init on channel better_player_channel)
E/flutter ( 9272): #0 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:165
E/flutter ( 9272): <asynchronous suspension>
E/flutter ( 9272):
E/flutter ( 9272): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method create on channel better_player_channel)
E/flutter ( 9272): #0 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:165
E/flutter ( 9272): <asynchronous suspension>
E/flutter ( 9272): #1 MethodChannelVideoPlayer.create
package:better_player/…/video_player/method_channel_video_player.dart:37
E/flutter ( 9272): <asynchronous suspension>
E/flutter ( 9272): #2 VideoPlayerController._create
package:better_player/…/video_player/video_player.dart:202
E/flutter ( 9272): <asynchronous suspension>
E/flutter ( 9272):
I/flutter ( 9272): GetDataFromUrl failed: SocketException: HTTP connection timed out after 0:00:05.000000, host: dash.akamaized.net, port: 443
Solution 1:[1]
What do you mean with 'copied'? No implementation for a method channel means that the code tries to call a method in the native environment on mentioned channel (better_player_channel), but it is not implemented. Sounds like you copied code and did not include the package in your yaml file. If you include it properly and get the dependencies then it should work. If you still get the error after installing the package, then you will need to contact the developer.
Solution 2:[2]
This is because you add better_player to your yaml and you do not recompile and reinstall your app to your device
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ehusmann |
Solution 2 | CerebrumOverflow |