Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error playing video - Trying to create a platform view of unregistered type: tv.mta/NativeVideoPlayer - 2.0.2-rc1 #86

Closed
lucascardo12 opened this issue Apr 27, 2022 · 6 comments
Assignees

Comments

@lucascardo12
Copy link

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: Trying to create a platform view of unregistered type: tv.mta/NativeVideoPlayer
E/flutter (10424): at io.flutter.plugin.platform.PlatformViewsController$1.createVirtualDisplayForPlatformView(PlatformViewsController.java:199)
E/flutter (10424): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:107)
E/flutter (10424): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:59)
E/flutter (10424): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/flutter (10424): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296)
E/flutter (10424): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:320)
E/flutter (10424): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12)
E/flutter (10424): at android.os.Handler.handleCallback(Handler.java:938)
E/flutter (10424): at android.os.Handler.dispatchMessage(Handler.java:99)
E/flutter (10424): at android.os.Looper.loopOnce(Looper.java:201)
E/flutter (10424): at android.os.Looper.loop(Looper.java:288)
E/flutter (10424): at android.app.ActivityThread.main(ActivityThread.java:7842)
E/flutter (10424): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (10424): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/flutter (10424): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
E/flutter (10424): , null, null)
E/flutter (10424): #0 StandardMethodCodec.decodeEnvelope
package:flutter/…/services/message_codecs.dart:607
E/flutter (10424): #1 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:177
E/flutter (10424):
E/flutter (10424): #2 TextureAndroidViewController._sendCreateMessage
package:flutter/…/services/platform_views.dart:1061
E/flutter (10424):
E/flutter (10424): #3 AndroidViewController.create
package:flutter/…/services/platform_views.dart:771
E/flutter (10424):
E/flutter (10424): #4 RenderAndroidView._sizePlatformView
package:flutter/…/rendering/platform_view.dart:191
E/flutter (10424):
E/flutter (10424):

@lucascardo12 lucascardo12 changed the title Error playing video - Trying to create a platform view of unregistered type: tv.mta/NativeVideoPlayer Error playing video - Trying to create a platform view of unregistered type: tv.mta/NativeVideoPlayer - 2.0.2-rc1 Apr 27, 2022
@KhuramKhalid KhuramKhalid self-assigned this Apr 29, 2022
@KhuramKhalid
Copy link
Member

Hello Lucas, so it seems the plugin need to be registered in your app's MainActivity class. Please see below how to do this.

Java

public class MainActivity extends FlutterActivity {

    @Override
    public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine);

        /* video player */
        tv.mta.flutter_playout.video.PlayerViewFactory.registerWith(
                flutterEngine.getPlatformViewsController().getRegistry(),
                flutterEngine.getDartExecutor().getBinaryMessenger(),
                this);

        /* audio player */
        tv.mta.flutter_playout.audio.AudioPlayer.registerWith(
                flutterEngine.getDartExecutor().getBinaryMessenger(),
                this,
                this.getContext());
    }
}

Kotlin

class MainActivity: FlutterActivity() {
    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        tv.mta.flutter_playout.video.PlayerViewFactory.registerWith(
                flutterEngine.platformViewsController.registry,
                flutterEngine.dartExecutor.binaryMessenger,
                this)

        tv.mta.flutter_playout.audio.AudioPlayer.registerWith(
                flutterEngine.dartExecutor.binaryMessenger,
                this, context)
    }
}

@lucascardo12
Copy link
Author

thanks, good work

@glennmichaelmejias
Copy link

error: cannot find symbol
public void configureFlutterEngine(@nonnull FlutterEngine flutterEngine

@glennmichaelmejias
Copy link

glennmichaelmejias commented Jun 22, 2022

to anyone having this issue, this is my full code in MainActivity.java

package com.example.app;

import io.flutter.embedding.android.FlutterActivity;

import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugins.GeneratedPluginRegistrant;

public class MainActivity extends FlutterActivity {
    @Override
    public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine);
        tv.mta.flutter_playout.video.PlayerViewFactory.registerWith(
                flutterEngine.getPlatformViewsController().getRegistry(),
                flutterEngine.getDartExecutor().getBinaryMessenger(),
                this);
        tv.mta.flutter_playout.audio.AudioPlayer.registerWith(
                            flutterEngine.getDartExecutor().getBinaryMessenger(),
                            this,
                            this.getContext());
    }
}

@hassanrehman01398
Copy link

This is causing error in await Firebase.initializeApp();

@indacurdev
Copy link

same error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants