[ad_1]
Requested
Considered
6 occasions
You have to create a video participant for IOS (AVPLayer ) utilizing Platform View. Can somebody share a hyperlink to some instance or write how it may be executed? I must implement precisely AVPlayer. I must implement it natively, with out utilizing packages.
Beneath is the code I wrote. My Flutter half:
class VideoPlayerPage extends StatefulWidget {
const VideoPlayerPage({Key? key}) : tremendous(key: key);
@override
State<VideoPlayerPage> createState() => _VideoPlayerPageState();
}
class _VideoPlayerPageState extends State<VideoPlayerPage> {
var videoUrl = "hyperlink";
@override
Widget construct(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Textual content('IOS Video Participant'),
),
physique: Column(
youngsters: [
Expanded(
child: VideoPlayerPlatformView(
videoUrl: videoUrl,
),
),
],
),
);
}
}
class VideoPlayerPlatformView extends StatelessWidget {
static const StandardMessageCodec _decoder = StandardMessageCodec();
last String videoUrl;
const VideoPlayerPlatformView({Key? key, required this.videoUrl}) : tremendous(key: key);
@override
Widget construct(BuildContext context) {
last Map<String, String> args = {"video_url": videoUrl};
if (defaultTargetPlatform == TargetPlatform.iOS) {
return UiKitView(
viewType: "VideoPlatformView",
creationParams: args,
creationParamsCodec: _decoder,
);
}
return Container();
}
}
My native Swift half:
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func software(
_ software: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
VideoPlayerPlugin.register(with: registrar(forPlugin: "VideoPlayer")!)
return tremendous.software(software, didFinishLaunchingWithOptions: launchOptions)
}
}
public class VideoPlayerPlugin {
class func register(with registrar: FlutterPluginRegistrar) {
let viewFactory = VideoPlayerFactory(messenger: registrar.messenger())
registrar.register(viewFactory, withId: "VideoPlatformView")
}
}
default
[ad_2]
