youtube_web_player 0.1.8 copy "youtube_web_player: ^0.1.8" to clipboard
youtube_web_player: ^0.1.8 copied to clipboard

A Flutter package for seamless integration of YouTube videos in a native WebView, providing a smooth playback experience. Ideal for multimedia applications.

youtube_web_player

Pub License: MIT


youtube_web_player #

A Flutter package for seamless integration of YouTube videos in a native WebView, providing a smooth playback experience. Ideal for multimedia applications.

Getting Started #

To use this package, add it to your pubspec.yaml:

dependencies:
  youtube_web_player: ^0.1.8

or run the command

flutter pub add youtube_web_player

Using the player #

import

import 'package:youtube_web_player/youtube_web_player.dart';

Full screen disable mode

YoutubeWebPlayer(videoId: 'NsJLhRGPv-M')

Full screen mode

YoutubeWebPlayer(
    videoId: 'NsJLhRGPv-M',
    isIframeAllowFullscreen: true,
    isAllowsInlineMediaPlayback: false,
);

Controller

// Initialize the controller for the YouTube video with the specified ID
YoutubeWebPlayerController? _controller = YoutubeWebPlayerController.getController("NsJLhRGPv-M");

// Get the duration of the video
Duration movieDuration = _controller?.value.duration;

// Get the current position of the video (playback time)
Duration position = _controller?.value.duration;

// Create a YoutubeWebPlayer widget to play the video with the specified ID
YoutubeWebPlayer(
    videoId: 'NsJLhRGPv-M',  // YouTube video ID
    controller: _controller   // Pass the controller for playback control
),

// Button to play the video
TextButton(
    onPressed: () {
        _controller?.play?.call(); // Start playing the video if the controller is available
        //_controller?.pause?.call(); // Commented out line to pause
    },
    child: Text("Play"), // Button text
),

// Button to rewind the video 5 seconds
TextButton(
    onPressed: () {
        // Seek the video forward by 5 seconds from the current position
        _controller!.seekTo!(position + Duration(seconds: 5))?.call();
    },
    child: Text(">>>"), // Button text
), 

// Button to fast-forward the video 5 seconds
TextButton(
    onPressed: () {
        // Seek the video backward by 5 seconds from the current position
        _controller!.seekTo!(position - Duration(seconds: 5))?.call();
    },
    child: Text("<<<"), // Button text
), 

Examples #

13
likes
0
points
102
downloads

Publisher

verified publisherrony.fun

Weekly Downloads

A Flutter package for seamless integration of YouTube videos in a native WebView, providing a smooth playback experience. Ideal for multimedia applications.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_inappwebview

More

Packages that depend on youtube_web_player