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

feat(video_player): support all platforms with video_player_media_kit #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions demos/video_player/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ This demo shows how to use Flutter's video_player plugin to play videos in WebF

## How to use

> This demo only works on Android/iOS devices.

Flutter version requirement: flutter 3.10.0

1. Make sure your devices are in the same WIFI network with your computer.
Expand Down
26 changes: 20 additions & 6 deletions demos/video_player/app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@
/// An example of using the plugin, controlling lifecycle and playback of the
/// video.

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:video_player/video_player.dart';
import 'package:video_player_media_kit/video_player_media_kit.dart';
import 'package:webf/webf.dart';

void main() {
VideoPlayerMediaKit.ensureInitialized(
android: Platform.isAndroid,
iOS: Platform.isIOS,
macOS: Platform.isMacOS,
windows: Platform.isWindows,
linux: Platform.isLinux,
);

WebF.defineCustomElement(
'video-player', (context) => VideoPlayerElement(context));

Expand Down Expand Up @@ -219,7 +229,8 @@ class _WebFRemoteVideo extends StatefulWidget {
State<StatefulWidget> createState() => _WebFRemoteVideoState();
}

class _WebFRemoteVideoState extends State<_WebFRemoteVideo> with AutomaticKeepAliveClientMixin {
class _WebFRemoteVideoState extends State<_WebFRemoteVideo>
with AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;

Expand All @@ -234,7 +245,8 @@ class _WebFRemoteVideoState extends State<_WebFRemoteVideo> with AutomaticKeepAl
}
}

class _BumbleBeeRemoteVideoState extends State<_BumbleBeeRemoteVideo> with AutomaticKeepAliveClientMixin {
class _BumbleBeeRemoteVideoState extends State<_BumbleBeeRemoteVideo>
with AutomaticKeepAliveClientMixin {
late VideoPlayerController _controller;

Future<ClosedCaptionFile> _loadCaptions() async {
Expand Down Expand Up @@ -521,9 +533,11 @@ class VideoPlayerElement extends WidgetElement {
@override
void initializeProperties(Map<String, BindingObjectProperty> properties) {
super.initializeProperties(properties);
properties['src'] = BindingObjectProperty(getter: () => getAttribute('src'), setter: (src) {
setAttribute('src', src);
});
properties['src'] = BindingObjectProperty(
getter: () => getAttribute('src'),
setter: (src) {
setAttribute('src', src);
});
}

@override
Expand Down
Loading