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

native_video_view 표지
패키지 상세v1.0.5

native_video_view

플랫폼의 네이티브 플레이어(안드로이드의 VideoView 및 iOS의 AVPlayer)를 사용하여 표시되는 비디오 플레이어 위젯입니다.

AndroidiOS
30일 다운로드
60
좋아요
51
Pub 점수
140

패키지 설치

flutter pub add native_video_view

패키지 개요

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

안드로이드의 VideoView와 iOS의 AVPlayer를 사용하여 플랫폼 네이티브 동영상 재생을 통합하는 플러터 패키지입니다. 소프트웨어 기반 솔루션 대신 네이티브 컴포넌트를 활용함으로써 부드럽고 고성능의 동영상 렌더링을 제공합니다. 다양한 동영상 형식과 하드웨어 가속 기능과의 호환성이 향상됩니다. 이 위젯은 안드로이드 및 iOS 플랫폼에서 최적의 동영상 재생 품질과 성능을 원하는 개발자를 위한 것입니다.

사용 사례

  • 하드웨어 가속을 사용하여 비디오 재생
  • 네이티브 비디오 컨트롤과의 통합
  • 복잡한 비디오 형식 지원
  • 미디어 집약형 애플리케이션 빌드
  • 저지연 재생 보장

주요 기능

  • Android 및 iOS에서 네이티브 비디오 플레이어 사용
  • 하드웨어 가속 비디오 렌더링
  • 최소한의 플러터 오버헤드
  • 크로스 플랫폼 일관성
  • 전체 화면 및 백그라운드 재생 지원

적합한 대상

  • 고성능이 필요한 미디어 앱
  • 풍부한 비디오 콘텐츠를 포함한 앱
  • 개발자들은 네이티브 재생 품질을 우선시합니다
  • 최소한의 사용자 정의 비디오 논리를 필요로 하는 프로젝트

고려 사항

  • 순수한 플러터 위젯에 비해 사용자 정의가 제한적입니다
  • 고급 기능을 사용하려면 플랫폼별 구성이 필요합니다
  • 모든 비디오 코덱을 기본적으로 지원하지 않을 수 있습니다
  • 네이티브 플랫폼 업데이트에 의존합니다
  • 사용자 정의 구현보다 UI 요소에 대한 제어가 적음

원본 README

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

native_video_view

A video player widget displayed using the platform native player (VideoView in Android and AVPlayer in iOS).

example_gif

Disclaimer

This plugin uses VideoView because in some devices the ExoPlayer plugin is not working correctly (due to decoders or something) and VideoView is a reasonable alternative. In iOS is sorta similar to Google's video_player so you should use their plugin if you want a player for iOS only.

Installation

First you need to add the dependency in your pubspec.yaml.

native_video_view: ^0.3.0

Then import the plugin in the .dart file you want to use it.

import 'package:native_video_view/native_video_view.dart';
Android

You need to add the necessary permissions to play the videos. If you are playing videos from the internet, you need to add the internet permissions in your AndroidManifest.xml located in the android folder in your project.

<uses-permission android:name="android.permission.INTERNET" />

If you are going to play videos from the device storage, you need to add the storage permissions.

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
iOS

In this platform you need to configure some options in your Info.plist file. This file is located in <project-root>/ios/Runner/ Info.plist.

First add the embedded views configuration.

<key>io.flutter.embedded_views_preview</key>
<true/>

If you want to play videos from the internet add the following.

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>

Usage

This plugin has a widget to use in your dart files. Example:

@override
Widget build(BuildContext context) {
return Scaffold(
    appBar: AppBar(
    title: const Text('Plugin example app'),
    ),
    body: Container(
    alignment: Alignment.center,
    child: NativeVideoView(
        keepAspectRatio: true,
        showMediaController: true,
        onCreated: (controller) {
          controller.setVideoSource(
            'assets/example.mp4',
            sourceType: VideoSourceType.asset,
          );
        },
        onPrepared: (controller, info) {
          controller.play();
        },
        onError: (controller, what, extra, message) {
          print('Player Error ($what | $extra | $message)');
        },
        onCompletion: (controller) {
          print('Video completed');
        },
        onProgress: (progress, duration) {
          print('$progress | $duration');
        },
      ),
    ),
  );
}

keepAspectRatio: Wraps the video player in a AspectRatio widget. The aspect ratio is calculated once the video is loaded. By default the aspect ratio is 4/3.

showMediaController: Shows a default media controller overlay in the video player widget.

enableVolumeControl: Adds an option in the MediaController to control the volume of the playback.

useExoPlayer: Use ExoPlayer as the underlying player. Android Only.

autoHide: Automatically hides the media controller after a few seconds of no use. Default is true.

autoHideTime: The time after which the controller is hidden. Default is 2 seconds.

onCreated: (required) Callback called when the PlatformView is finished creating.

onPrepared: (required) Callback called when the player has finished loading the video.

onCompletion: (required) Callback called when the video reached the end.

onError: Callback called if an error occurs in the player.

onProgress: Callback used to notify progress in the video playback.

AudioFocus

To make the player get the audio focus of the system you just have to use the setting requestAudioFocus when setting the video source. See the example below.

@override
Widget build(BuildContext context) {
    return NativeVideoView(
       onCreated: (controller) {
         controller.setVideoSource(
             'assets/example.mp4',
             requestAudioFocus: true,
             sourceType: VideoSourceType.asset,
         );
       },
    );
}

카테고리

의존성

의존성 목록 2 개

소스 저장소

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

아직 데이터가 없습니다.