Skip to content

Commit

Permalink
deps: package:media_kit to 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaoMint committed Jul 12, 2023
1 parent 1a691be commit eabd357
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 85 deletions.
16 changes: 7 additions & 9 deletions lib/pages/watch/widgets/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import 'package:window_manager/window_manager.dart';
import 'package:screenshot/screenshot.dart';
import 'playlist.dart' as p;
import 'package:path/path.dart' as path;
import 'package:wakelock_plus/wakelock_plus.dart';

class VideoPlayer extends StatefulWidget {
const VideoPlayer({
Expand Down Expand Up @@ -70,31 +69,31 @@ class _VideoPlayerState extends State<VideoPlayer> {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
}
_play();
player.streams.playing.listen((event) {
player.stream.playing.listen((event) {
setState(() {
isPlaying = event;
});
});
player.streams.duration.listen((event) {
player.stream.duration.listen((event) {
setState(() {
duration = event;
});
});
player.streams.position.listen((event) {
player.stream.position.listen((event) {
if (!isSeeking) {
setState(() {
position = event;
});
}
});
player.streams.error.listen((event) {
player.stream.error.listen((event) {
if (event.toString().isNotEmpty) {
setState(() {
error = event.toString();
});
}
});
player.streams.completed.listen((event) {
player.stream.completed.listen((event) {
if (playerIndex == widget.playList.length - 1) {
if (Platform.isAndroid) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
Expand All @@ -117,7 +116,6 @@ class _VideoPlayerState extends State<VideoPlayer> {

@override
void dispose() {
WakelockPlus.disable();
if (Platform.isAndroid) {
// 切换回竖屏
SystemChrome.setPreferredOrientations(
Expand Down Expand Up @@ -165,12 +163,11 @@ class _VideoPlayerState extends State<VideoPlayer> {
_play() async {
isLoading = true;
try {
await WakelockPlus.enable();
final m3u8Url =
(await widget.runtime.watch(widget.playList[playerIndex].url)).url;
debugPrint(m3u8Url);
player.open(Media(m3u8Url));
player.streams.buffering.listen((event) {
player.stream.buffering.listen((event) {
debugPrint(event.toString());
isLoading = event;
});
Expand Down Expand Up @@ -542,6 +539,7 @@ class _VideoPlayerState extends State<VideoPlayer> {
child: Video(
key: ValueKey(playerIndex),
controller: controller,
controls: (state) => const SizedBox.shrink(),
),
),
Positioned.fill(
Expand Down
8 changes: 4 additions & 4 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ import FlutterMacOS
import Foundation

import desktop_multi_window
import device_info_plus
import flutter_js
import isar_flutter_libs
import media_kit_libs_macos_video
import media_kit_video
import package_info_plus
import path_provider_foundation
import screen_brightness_macos
import screen_retriever
import system_theme
import url_launcher_macos
import wakelock_plus
import wakelock_macos
import window_manager

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FlutterMultiWindowPlugin.register(with: registry.registrar(forPlugin: "FlutterMultiWindowPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FlutterJsPlugin.register(with: registry.registrar(forPlugin: "FlutterJsPlugin"))
IsarFlutterLibsPlugin.register(with: registry.registrar(forPlugin: "IsarFlutterLibsPlugin"))
MediaKitLibsMacosVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitLibsMacosVideoPlugin"))
MediaKitVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitVideoPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
ScreenBrightnessMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenBrightnessMacosPlugin"))
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
SystemThemePlugin.register(with: registry.registrar(forPlugin: "SystemThemePlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin"))
WakelockMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockMacosPlugin"))
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
}
Loading

0 comments on commit eabd357

Please sign in to comment.