This repository has been archived by the owner on Jan 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
youtube_plyr_iframe.dart
65 lines (56 loc) · 2.15 KB
/
youtube_plyr_iframe.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2020 Sarbagya Dhaubanjar. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'src/controller.dart';
import 'src/helpers/youtube_value_provider.dart';
import 'src/players/youtube_player_mobile.dart'
if (dart.library.html) 'src/players/youtube_player_web.dart';
export 'src/controller.dart';
export 'src/enums/playback_rate.dart';
export 'src/enums/player_state.dart';
export 'src/enums/playlist_type.dart';
export 'src/enums/thumbnail_quality.dart';
export 'src/enums/youtube_error.dart';
export 'src/helpers/youtube_value_builder.dart';
export 'src/helpers/youtube_value_provider.dart';
export 'src/meta_data.dart';
export 'src/player_params.dart';
/// A widget to play or stream Youtube Videos.
class YoutubePlayerIFrame extends StatelessWidget {
/// The [controller] for this player.
final YoutubePlayerController? controller;
/// Aspect ratio for the player.
final double aspectRatio;
/// Which gestures should be consumed by the youtube player.
///
/// It is possible for other gesture recognizers to be competing with the player on pointer
/// events, e.g if the player is inside a [ListView] the [ListView] will want to handle
/// vertical drags. The player will claim gestures that are recognized by any of the
/// recognizers on this list.
///
/// By default vertical and horizontal gestures are absorbed by the player.
/// Passing an empty set will ignore the defaults.
///
/// This is ignored on web.
final Set<Factory<OneSequenceGestureRecognizer>>? gestureRecognizers;
/// A widget to play or stream Youtube Videos.
const YoutubePlayerIFrame({
Key? key,
this.controller,
this.aspectRatio = 16 / 10,
this.gestureRecognizers,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return AspectRatio(
aspectRatio: aspectRatio,
child: RawYoutubePlayer(
controller: controller ?? context.ytController,
gestureRecognizers: gestureRecognizers,
),
);
}
}