패키지, 저장소 및 앱 카테고리 검색

패키지 상세v3.3.1

video_player_win

Windows용 비디오 플레이어, 가볍고 Windows 내장 미디어 포화 API를 사용합니다. video_player 플러그인의 Windows 구현입니다.

Windows
30일 다운로드
17.3만
좋아요
71
Pub 점수
150

패키지 설치

flutter pub add video_player_win

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

효율적인 비디오 재생을 위해 네이티브 Media Foundation API를 활용한 가벼운 윈도우용 video_player 플러그인 구현체입니다. 윈도우 전용으로 설계되어 데스크톱 플랫폼을 대상으로 한 Flutter 애플리케이션과 원활하게 통합됩니다. 이 패키지는 최소한의 오버헤드로 부드러운 비디오 렌더링을 가능하게 하며, 윈도우 시스템에서 신뢰할 수 있는 미디어 재생이 필요한 앱에 이상적입니다. 더 넓은 video_player 생태계의 일부로서 추가 종속성 없이 윈도우 지원 기능을 확장합니다.

사용 사례

  • 데스크톱 앱에서 로컬 비디오 파일 재생하기
  • Windows Flutter 애플리케이션에서 비디오 스트리밍
  • 윈도우 기반 멀티미디어 도구에 비디오 재생 기능 통합
  • 크로스 플랫폼 데스크톱 앱에서 비디오 콘텐츠 지원
  • Windows에서 하드웨어 가속 재생 사용

주요 기능

  • Windows Media Foundation API 사용
  • 경량이고 효율적
  • Windows에서의 네이티브 성능
  • video_player와의 원활한 통합
  • Flutter를 통한 크로스 플랫폼 호환성

적합한 대상

  • 윈도우 데스크톱을 대상으로 하는 플러터 개발자
  • Windows에서 네이티브 비디오 재생을 필요로 하는 앱
  • 미디어가 풍부한 데스크톱 애플리케이션
  • 다중 플랫폼에서 video_player를 사용하는 개발자
  • 저수준 미디어 제어가 필요한 프로젝트

고려 사항

  • 윈도우 전용 플랫폼 지원
  • Windows 7 이상이 필요합니다
  • 데스크톱 환경에 한정
  • video_player 핵심 플러그인에 의존합니다
  • Linux 또는 macOS 지원 없음

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

video_player_win

Flutter video player for Windows, lightweight, using Windows built-in Media Foundation API. Windows implementation of the video_player plugin.

Platform Support

This package itself support only Windows.

But use it with video_player, your app can support Windows / Android / iOS / Web at the same time.

Built-in control panel & Fullscreen & Subtitle support

Please use package video_player_control_panel instead.

Which also use this package to play video on Windows.

Features & Limitations

Features:

  • GPU hardware acceleration, low CPU usage (maybe support 4K 60fps video?)
  • No GPL / LGPL 3rd-party libraries inside.
  • Only one dll file (~130 KB) added as a plugin.
  • Support Windows / Android / iOS / Web by collaboration with video_player

Limitations:

  • This package doesn't support HLS (.m3u8)

But, since this package use Microsoft Media Foundation API, there are some limtations:

  • Playback will use codecs preloaded in Windows OS. If you want to play some video format that not supported by these preloaded codecs, you need to install 3rd-party codecs exe file, about 18 MB. (see the next section).

Supported Formats in Windows (Important !)

Ref: Windows preloaded codec list

This package use Windows built-in Media Foundation API. So playback video will use the codecs preload in your Windows environment. All the media format can be played by WMP (Windows Media Player) can also be played by this package. However, the preloaded codecs in Windows is limited.

If you have a media file cannot played by this package, ALSO CANNOT played by WMP (Windows Media Player), it means that this media file is not support by codecs preloaded in your Windows.

In this case, please install ONE of the following codec pack into your Windows:

You can auto-install codec by the following Dart code:

import 'dart:io';

Process.run('E:\\K-Lite_Codec_Pack_1730_Basic.exe', ['/silent']).then((value) {
  if (value.exitCode == 0) log("installation success");
  else log("installation failed");
});

After install the codec pack, most of the media format are supported.

Supported AV1 video

To play AV1 video,

You can silently auto-install codec by the following Dart code:

import 'dart:io';

Process.run('powershell', ['Add-AppxPackage', '-Path', 'E:\\av1-video-extension-1-1-52851-0.appx']).then((value) {
  if (value.exitCode == 0) log("installation success");
  else log("installation failed");
});

Problem shootting for building fail

If you build fail with this package, and the error message has the keyword "MSB3073":

  • run "flutter build windows" in command line in [Administrator] mode

Quick Start

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  video_player: ^2.5.1
  video_player_win: ^3.0.0

Usage

video / audio playback

Play from network source:

var controller = VideoPlayerController.network("https://www.your-web.com/sample.mp4");
controller.initialize().then((value) {
  if (controller.value.isInitialized) {
    controller.play();
  } else {
    log("video file load failed");
  }
}).catchError((e) {
  log("controller.initialize() error occurs: $e");
});

Play from file:

var controller = VideoPlayerController.file(File("E:\\test.mp4"));

If the file is a video, build a display widget to show video frames:

Widget build(BuildContext context) {
  return VideoPlayer(controller);
}

operations

  • Play: controller.play();
  • Pause: controller.pause();
  • Seek: controller.seekTo( Duration(minute: 10, second:30) );
  • set playback speed: (normal speed: 1.0) controller.setPlaybackSpeed(1.5);
  • set volume: (max: 1.0 , mute: 0.0) controller.setVolume(0.5);
  • set looping: controller.setLooping(true);
  • free resource: controller.dispose();

Listen playback events and values

void onPlaybackEvent() {
	final value = controller.value;
	// value.isInitialized (bool)
	// value.size (Size, video size)
	// value.duration (Duration)
	// value.isPlaying (bool)
	// value.isBuffering (bool)
	// value.isCompleted (bool)
	// value.position (Duration)
}
controller.addListener(onPlaybackEvent);
...
controller.removeListener(onPlaybackEvent); // remember to removeListener()

Release resource

controller.dispose();

Keep aspect ratio of VideoPlayer

Widget player = Container(
  color: Colors.black,
  child: Center(
    child: AspectRatio(
      aspectRatio: controller!.value.aspectRatio,
      child: VideoPlayer(controller!),
    ),
  ),
);

standalone mode

If your app only runs on Windows, and you want to remove library dependencies as many as possible, you can modify pubspec.yaml file:

dependencies:
  # video_player: ^2.4.7 # mark this line, for Windows only app
  video_player_win:

and modify all the following class name in your code:

VideoPlayer -> WinVideoPlayer  // add "Win" prefix
VideoPlayerController -> WinVideoPlayerController  // add "Win" prefix

just only modify class names. All the properties / method are the same with video_player

Example

import 'dart:developer';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:video_player_win/video_player_win.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  late VideoPlayerController controller;

  @override
  void initState() {
    super.initState();
    controller = VideoPlayerController.file(File("E:\\test_youtube.mp4"));
    controller.initialize().then((value) {
      if (controller.value.isInitialized) {
        controller.play();
        setState(() {});
      } else {
        log("video file load failed");
      }
    });
  }

  @override
  void dispose() {
    super.dispose();
    controller.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('video_player_win example app'),
        ),

        body: Stack(children: [
          VideoPlayer(controller),
          Positioned(
            bottom: 0,
            child: Column(children: [
              ValueListenableBuilder(
                valueListenable: controller,
                builder: ((context, value, child) {
                  int minute = controller.value.position.inMinutes;
                  int second = controller.value.position.inSeconds % 60;
                  return Text("$minute:$second", style: Theme.of(context).textTheme.headline6!.copyWith(color: Colors.white, backgroundColor: Colors.black54));
                }),
              ),
              ElevatedButton(onPressed: () => controller.play(), child: const Text("Play")),
              ElevatedButton(onPressed: () => controller.pause(), child: const Text("Pause")),
              ElevatedButton(onPressed: () => controller.seekTo(Duration(milliseconds: controller.value.position.inMilliseconds+ 10*1000)), child: const Text("Forward")),
            ])),
        ]),
      ),
    );
  }
}

카테고리

의존성

의존성 목록 2 개

  • plugin_platform_interface^2.0.2
  • video_player_platform_interface^6.2.1

소스 저장소

이 패키지를 사용하는 프로젝트

순위