Skip to content

Commit

Permalink
Merge pull request #961 from sarbagyastha/develop
Browse files Browse the repository at this point in the history
Version 5.1.3
  • Loading branch information
sarbagyastha authored Jul 1, 2024
2 parents 91e29f7 + 37ed960 commit e83fd21
Show file tree
Hide file tree
Showing 32 changed files with 314 additions and 264 deletions.
28 changes: 0 additions & 28 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

61 changes: 61 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Bug Report
description: File a report to help improve the player
title: "[BUG] <title>"
labels: ["Bug", "Needs Triage"]
assignees:
- sarbagyastha
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search to see if an issue already exists for the bug you encountered.
options:
- label: I have searched the existing issues
required: true
- type: dropdown
id: package
attributes:
label: Package
description: Which package are you reporting bug for?
options:
- youtube_player_iframe (Default)
- youtube_player_flutter
default: 0
validations:
required: true
- type: textarea
id: desc
attributes:
label: What happened?
description: A clear and concise description of what the bug is.
validations:
required: true
- type: textarea
id: expected
attributes:
label: What is the expected behaviour?
description: A clear and concise description of what you expected to happen.
validations:
required: true
- type: textarea
id: steps
attributes:
label: How to reproduce?
description: Steps to reproduce the behavior.
placeholder: |
1. In this environment...
2. With this config...
3. Run '...'
4. See error...
validations:
required: true
- type: textarea
id: logs
attributes:
label: Flutter Doctor Output
description: Paste the output of `flutter doctor -v`
render: shell
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
2 changes: 1 addition & 1 deletion .github/workflows/web-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: macos-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
- uses: sarbagyastha/flutter-gh-pages@main
with:
Expand Down
14 changes: 9 additions & 5 deletions packages/youtube_player_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ void main() {
statusBarColor: Colors.blueAccent,
),
);
runApp(YoutubePlayerDemoApp());
runApp(const YoutubePlayerDemoApp());
}

/// Creates [YoutubePlayerDemoApp] widget.
class YoutubePlayerDemoApp extends StatelessWidget {
const YoutubePlayerDemoApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
Expand All @@ -38,15 +40,17 @@ class YoutubePlayerDemoApp extends StatelessWidget {
color: Colors.blueAccent,
),
),
home: MyHomePage(),
home: const MyHomePage(),
);
}
}

/// Homepage
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});

@override
_MyHomePageState createState() => _MyHomePageState();
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
Expand Down Expand Up @@ -180,7 +184,7 @@ class _MyHomePageState extends State<MyHomePage> {
onPressed: () => Navigator.push(
context,
CupertinoPageRoute(
builder: (context) => VideoList(),
builder: (context) => const VideoList(),
),
),
),
Expand Down Expand Up @@ -220,7 +224,7 @@ class _MyHomePageState extends State<MyHomePage> {
controller: _idController,
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Enter youtube \<video id\> or \<link\>',
hintText: 'Enter youtube <video id> or <link>',
fillColor: Colors.blueAccent.withAlpha(20),
filled: true,
hintStyle: const TextStyle(
Expand Down
10 changes: 6 additions & 4 deletions packages/youtube_player_flutter/example/lib/video_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import 'package:youtube_player_flutter/youtube_player_flutter.dart';

/// Creates list of video players
class VideoList extends StatefulWidget {
const VideoList({super.key});

@override
_VideoListState createState() => _VideoListState();
State<VideoList> createState() => _VideoListState();
}

class _VideoListState extends State<VideoList> {
Expand Down Expand Up @@ -40,11 +42,11 @@ class _VideoListState extends State<VideoList> {
key: ObjectKey(_controllers[index]),
controller: _controllers[index],
actionsPadding: const EdgeInsets.only(left: 16.0),
bottomActions: [
bottomActions: const [
CurrentPosition(),
const SizedBox(width: 10.0),
SizedBox(width: 10),
ProgressBar(isExpanded: true),
const SizedBox(width: 10.0),
SizedBox(width: 10),
RemainingDuration(),
FullScreenButton(),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@ import '../utils/youtube_player_controller.dart';
///
/// Use [YoutubePlayer] instead.
class RawYoutubePlayer extends StatefulWidget {
/// Sets [Key] as an identification to underlying web view associated to the player.
final Key? key;

/// {@macro youtube_player_flutter.onEnded}
final void Function(YoutubeMetaData metaData)? onEnded;

/// Creates a [RawYoutubePlayer] widget.
RawYoutubePlayer({
this.key,
const RawYoutubePlayer({
super.key,
this.onEnded,
});

/// {@macro youtube_player_flutter.onEnded}
final void Function(YoutubeMetaData metaData)? onEnded;

@override
_RawYoutubePlayerState createState() => _RawYoutubePlayerState();
State<RawYoutubePlayer> createState() => _RawYoutubePlayerState();
}

class _RawYoutubePlayerState extends State<RawYoutubePlayer>
Expand Down
53 changes: 25 additions & 28 deletions packages/youtube_player_flutter/lib/src/player/youtube_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,26 @@ import 'raw_youtube_player.dart';
/// ```
///
class YoutubePlayer extends StatefulWidget {
/// Sets [Key] as an identification to underlying web view associated to the player.
final Key? key;
/// Creates [YoutubePlayer] widget.
const YoutubePlayer({
super.key,
required this.controller,
this.width,
this.aspectRatio = 16 / 9,
this.controlsTimeOut = const Duration(seconds: 3),
this.bufferIndicator,
Color? progressIndicatorColor,
ProgressBarColors? progressColors,
this.onReady,
this.onEnded,
this.liveUIColor = Colors.red,
this.topActions,
this.bottomActions,
this.actionsPadding = const EdgeInsets.all(8.0),
this.thumbnail,
this.showVideoProgressIndicator = false,
}) : progressColors = progressColors ?? const ProgressBarColors(),
progressIndicatorColor = progressIndicatorColor ?? Colors.red;

/// A [YoutubePlayerController] to control the player.
final YoutubePlayerController controller;
Expand Down Expand Up @@ -130,27 +148,6 @@ class YoutubePlayer extends StatefulWidget {
/// {@endtemplate}
final bool showVideoProgressIndicator;

/// Creates [YoutubePlayer] widget.
const YoutubePlayer({
this.key,
required this.controller,
this.width,
this.aspectRatio = 16 / 9,
this.controlsTimeOut = const Duration(seconds: 3),
this.bufferIndicator,
Color? progressIndicatorColor,
ProgressBarColors? progressColors,
this.onReady,
this.onEnded,
this.liveUIColor = Colors.red,
this.topActions,
this.bottomActions,
this.actionsPadding = const EdgeInsets.all(8.0),
this.thumbnail,
this.showVideoProgressIndicator = false,
}) : progressColors = progressColors ?? const ProgressBarColors(),
progressIndicatorColor = progressIndicatorColor ?? Colors.red;

/// Converts fully qualified YouTube Url to video id.
///
/// If videoId is passed as url then no conversion is done.
Expand Down Expand Up @@ -187,7 +184,7 @@ class YoutubePlayer extends StatefulWidget {
: 'https://i3.ytimg.com/vi/$videoId/$quality.jpg';

@override
_YoutubePlayerState createState() => _YoutubePlayerState();
State<YoutubePlayer> createState() => _YoutubePlayerState();
}

class _YoutubePlayerState extends State<YoutubePlayer> {
Expand Down Expand Up @@ -370,15 +367,15 @@ class _YoutubePlayerState extends State<YoutubePlayer> {
children: widget.bottomActions ??
[
const SizedBox(width: 14.0),
CurrentPosition(),
const CurrentPosition(),
const SizedBox(width: 8.0),
ProgressBar(
isExpanded: true,
colors: widget.progressColors,
),
RemainingDuration(),
const RemainingDuration(),
const PlaybackSpeedButton(),
FullScreenButton(),
const FullScreenButton(),
],
),
),
Expand All @@ -404,7 +401,7 @@ class _YoutubePlayerState extends State<YoutubePlayer> {
),
],
if (!controller.flags.hideControls)
Center(
const Center(
child: PlayPauseButton(),
),
if (controller.value.hasError) errorWidget,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:developer';

import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
Expand Down Expand Up @@ -168,11 +170,11 @@ class YoutubePlayerController extends ValueNotifier<YoutubePlayerValue> {
?.controller;
}

_callMethod(String methodString) {
void _callMethod(String methodString) {
if (value.isReady) {
value.webViewController?.evaluateJavascript(source: methodString);
} else {
print('The controller is not ready for method calls.');
log('The controller is not ready for method calls.');
}
}

Expand Down Expand Up @@ -316,15 +318,16 @@ class YoutubePlayerController extends ValueNotifier<YoutubePlayerValue> {
class InheritedYoutubePlayer extends InheritedWidget {
/// Creates [InheritedYoutubePlayer]
const InheritedYoutubePlayer({
Key? key,
super.key,
required this.controller,
required Widget child,
}) : super(key: key, child: child);
required super.child,
});

/// A [YoutubePlayerController] which controls the player.
final YoutubePlayerController controller;

@override
bool updateShouldNotify(InheritedYoutubePlayer oldPlayer) =>
oldPlayer.controller.hashCode != controller.hashCode;
bool updateShouldNotify(InheritedYoutubePlayer oldWidget) {
return oldWidget.controller.hashCode != controller.hashCode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class CurrentPosition extends StatefulWidget {
final YoutubePlayerController? controller;

/// Creates [CurrentPosition] widget.
CurrentPosition({this.controller});
const CurrentPosition({super.key, this.controller});

@override
_CurrentPositionState createState() => _CurrentPositionState();
State<CurrentPosition> createState() => _CurrentPositionState();
}

class _CurrentPositionState extends State<CurrentPosition> {
Expand Down Expand Up @@ -66,14 +66,14 @@ class _CurrentPositionState extends State<CurrentPosition> {

/// A widget which displays the remaining duration of the video.
class RemainingDuration extends StatefulWidget {
/// Creates [RemainingDuration] widget.
const RemainingDuration({super.key, this.controller});

/// Overrides the default [YoutubePlayerController].
final YoutubePlayerController? controller;

/// Creates [RemainingDuration] widget.
RemainingDuration({this.controller});

@override
_RemainingDurationState createState() => _RemainingDurationState();
State<RemainingDuration> createState() => _RemainingDurationState();
}

class _RemainingDurationState extends State<RemainingDuration> {
Expand Down
Loading

0 comments on commit e83fd21

Please sign in to comment.