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

패키지 상세v2.1.0

y_player

YPlayer는 사용하기 쉬운 YouTube 비디오 플레이어 위젯을 제공하는 Flutter 패키지입니다

AndroidiOSmacOSWindowsLinux
30일 다운로드
132
좋아요
27
Pub 점수
150

패키지 설치

flutter pub add y_player

패키지 개요

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

YPlayer는 Flutter 애플리케이션에 YouTube 비디오를 쉽게 통합할 수 있도록 도와주는 Flutter 패키지입니다. 다양한 플랫폼에서 YouTube 콘텐츠를 원활하게 임베드하고 재생할 수 있도록 사용자 정의 가능한 비디오 플레이어 위젯을 제공합니다. 최소한의 설정으로 비디오 ID 또는 URL을 사용하여 YouTube 비디오를 표시할 수 있으며, 반응형 디자인과 기본 재생 컨트롤을 지원합니다. 각 플랫폼의 네이티브 YouTube 플레이어를 활용하여 최적의 성능과 호환성을 보장합니다.

사용 사례

  • 앱에 YouTube 동영상 삽입하기
  • 교육 콘텐츠 플레이어 만들기
  • 미디어가 풍부한 Flutter 애플리케이션 빌드
  • 비디오 튜토리얼 통합
  • 스트리밍 또는 엔터테인먼트 앱 개발

주요 기능

  • 비디오 ID 또는 URL을 사용한 간단한 비디오 임베딩
  • Android, iOS, macOS, Windows 및 Linux 지원
  • 반응성 있고 사용자 정의 가능한 플레이어 UI
  • 내장 재생 컨트롤
  • 네이티브 YouTube 플레이어 통합

적합한 대상

  • 미디어 앱을 구축하는 플러터 개발자
  • 교육 앱 제작자
  • 비디오 라이브러리가 있는 콘텐츠 플랫폼
  • YouTube 비디오 재생이 필요한 앱

고려 사항

  • 비디오 로딩을 위해 인터넷 연결이 필요합니다
  • 기본 제어를 넘어서는 맞춤 설정이 제한적입니다
  • YouTube API 사용 가능 여부에 따라 다릅니다
  • 특정 플랫폼에 대해 추가 권한이 필요할 수 있습니다
  • 오프라인 비디오 재생에 적합하지 않습니다

원본 README

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

YPlayer

Pub

Logo

YPlayer is a Flutter package that provides an easy-to-use YouTube video player widget. It leverages the power of the youtube_explode_dart package for fetching video information.

Features

  • Play YouTube videos directly in your Flutter app
  • Support for fullscreen mode
  • Optional autoplay
  • Video Quality selection
  • Playback speed control
  • Customizable loading and error widgets
  • Easy to use API with play, pause, and stop functionality
  • Callback support for player state changes and progress updates
  • Customizable progress bar colors
  • Improved handling of app lifecycle changes and fullscreen mode
  • Enhanced error handling and recovery
  • Separate handling of video and audio streams for better quality

Installation

Add y_player to your pubspec.yaml file:

dependencies:
  y_player: ^2.0.0

Then run:

flutter pub get

Usage

First, ensure that you initialize the YPlayer in your main.dart:

import 'package:flutter/material.dart';
import 'package:y_player/y_player_main.dart';

void main() {
  YPlayerInitializer.ensureInitialized();
  runApp(MyApp());
}

Here's a simple example of how to use YPlayer in your Flutter app:

import 'package:flutter/material.dart';
import 'package:y_player/y_player_main.dart';

class MyVideoPlayer extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('YPlayer Example')),
      body: YPlayer(
        youtubeUrl: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
        onStateChanged: (status) {
          print('Player Status: $status');
        },
        onProgressChanged: (position, duration) {
          print('Progress: ${position.inSeconds}/${duration.inSeconds}');
        },
        onControllerReady: (controller) {
          print('Controller is ready!');
        },
      ),
    );
  }
}

Migrating to 2.0.0

Version 2.0.0 introduces significant changes to address the deprecation of muxed streams in YouTube and to improve overall performance. Here are the key changes:

To migrate your existing code:

  1. Update your pubspec.yaml to use version 2.0.0 or later of y_player.

  2. In your main.dart, add the initialization call:

void main() {
  YPlayerInitializer.ensureInitialized();
  runApp(MyApp());
}
  1. Update your YPlayer widget usage. The basic usage remains the same, but some properties have changed:
YPlayer(
  youtubeUrl: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
  color: Colors.red, // New property for customizing controls color
  // materialProgressColors and cupertinoProgressColors are no longer available
)
  1. If you were using ChewieController directly, you'll need to update to use YPlayerController instead.

These changes address the deprecation of muxed streams in YouTube and provide a more robust and efficient video playback experience. The separate handling of video and audio streams allows for better quality options and more flexibility in playback.

API Reference

YPlayer

Constructor:

YPlayer({
  Key? key,
  required String youtubeUrl,
  double? aspectRatio,
  bool autoPlay = true,
  Color? color,
  Widget? placeholder,
  Widget? loadingWidget,
  Widget? errorWidget,
  YPlayerStateCallback? onStateChanged,
  YPlayerProgressCallback? onProgressChanged,
  Function(YPlayerController controller)? onControllerReady,
})
YPlayerController

Methods:

  • play(): Starts or resumes video playback.
  • pause(): Pauses video playback.
  • stop(): Stops video playback and resets to the beginning.

Properties:

  • status: Gets the current status of the player (YPlayerStatus enum).
  • position: Gets the current playback position (Duration).
  • duration: Gets the total duration of the video (Duration).
  • isInitialized: Returns true if the player is fully initialized.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

카테고리

의존성

의존성 목록 4 개

소스 저장소

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

아직 데이터가 없습니다.