flutter_macos_video_player icon indicating copy to clipboard operation
flutter_macos_video_player copied to clipboard

Can you provide some sample code?

Open bullets-jyr opened this issue 2 years ago • 4 comments

I installed the package as instructed in the readme, but I don't know how to use it. Can you provide some sample code?

bullets-jyr avatar Apr 11 '23 10:04 bullets-jyr

It’s the same as the normal video player for iOS and Android.

ollyde avatar Apr 11 '23 12:04 ollyde

thank you for the reply. I am jiyoung ryu, an android and flutter junior developer working on a project that needs to play a video in a desktop app on macos. I have one more question for you. I'm confused about the depencies. Here is my pubsupec.yaml:

video_player: ^2.4.4 video_player_macos: 2.0.1

When you apply these two things, do you mean that it is possible to create a macos video play desktop app?

bullets-jyr avatar Apr 11 '23 13:04 bullets-jyr

class HomeScreen extends StatefulWidget { const HomeScreen({Key? key}) : super(key: key);

@override State<HomeScreen> createState() => _HomeScreenState(); }

class _HomeScreenState extends State<HomeScreen> { VideoPlayerController? videoPlayerController;

@override void initState() { super.initState();

initializeVideoPlayerController();

}

initializeVideoPlayerController() async { videoPlayerController = VideoPlayerController.asset('assets/video/sample.mp4');

await videoPlayerController!.initialize();

}

@override Widget build(BuildContext context) { return GestureDetector( onTap: () { videoPlayerController!.play(); }, child: VideoPlayer( videoPlayerController!, ), ); } }

The above code was written based on when I used the video_player library after seeing the answer "It’s the same as the normal video player for iOS and Android." But the video doesn't play on macOS. can you tell me what i did wrong? Any help please?

bullets-jyr avatar Apr 12 '23 00:04 bullets-jyr

This is the error log when building the code above. how can i solve it?

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(video_player, not implemented, null, null) #0 VideoPlayerMacOsApi.create (package:video_player_macos/src/messages.g.dart:298:7) #1 VideoPlayerMacOs.create (package:video_player_macos/src/video_player_macos.dart:65:37) #2 VideoPlayerController.initialize (package:video_player/video_player.dart:404:19) #3 _HomeScreenState.initializeVideoPlayerController (package:vid_player_macos/screen/home_screen.dart:24:5)

bullets-jyr avatar Apr 12 '23 00:04 bullets-jyr