Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/video_player/video_player_macos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.0.1

* Initial release.
1 change: 1 addition & 0 deletions packages/video_player/video_player_macos/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO: Add your license here.
34 changes: 34 additions & 0 deletions packages/video_player/video_player_macos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# video_player_macos

The macos implementation of [`video_player`][1].

## Usage

### Import the package

This package has been endorsed, meaning that you only need to add `video_player`
as a dependency in your `pubspec.yaml`. It will be automatically included in your app
when you depend on `package:video_player`.

This is what the above means to your `pubspec.yaml`:

```yaml
...
dependencies:
...
video_player: ^2.0.3
...
```

If you wish to use the macos package only, you can add `video_player_macos` as a
dependency:

```yaml
...
dependencies:
...
video_player_macos: ^0.0.1
...
```

[1]: ../video_player/video_player
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib/generated_plugin_registrant.dart
10 changes: 10 additions & 0 deletions packages/video_player/video_player_macos/example/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: c5a4b4029c0798f37c4a39b479d7cb75daa7b05c
channel: beta

project_type: app
8 changes: 8 additions & 0 deletions packages/video_player/video_player_macos/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# video_player_example

Demonstrates how to use the video_player plugin.

## Getting Started

For help getting started with Flutter, view our online
[documentation](https://flutter.dev/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1
00:00:00,200 --> 00:00:01,750
[ Birds chirping ]

2
00:00:02,300 --> 00:00:05,000
[ Buzzing ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
// Copyright 2019, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// TODO(amirh): Remove this once flutter_driver supports null safety.
// https://github.com/flutter/flutter/issues/71379
// @dart = 2.9
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:integration_test/integration_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:video_player/video_player.dart';

const Duration _playDuration = Duration(seconds: 1);

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
VideoPlayerController _controller;
tearDown(() async => _controller.dispose());

group('network videos', () {
setUp(() {
_controller = VideoPlayerController.network(
'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4',
);
});

testWidgets('can be initialized', (WidgetTester tester) async {
await _controller.initialize();

expect(_controller.value.isInitialized, true);
expect(_controller.value.position, const Duration(seconds: 0));
expect(_controller.value.isPlaying, false);
expect(_controller.value.duration,
const Duration(seconds: 4, milliseconds: 036));
});

testWidgets('can be played', (WidgetTester tester) async {
await _controller.initialize();
await _controller.play();
await tester.pumpAndSettle(_playDuration);

expect(_controller.value.isPlaying, true);
expect(_controller.value.position,
(Duration position) => position > const Duration(seconds: 0));
});

testWidgets('can seek', (WidgetTester tester) async {
await _controller.initialize();

await _controller.seekTo(const Duration(seconds: 3));

expect(_controller.value.position, const Duration(seconds: 3));
});

testWidgets(
'can be paused',
(WidgetTester tester) async {
await _controller.initialize();
// Play for a second, then pause, and then wait a second.
await _controller.play();
await tester.pumpAndSettle(_playDuration);
await _controller.pause();
final Duration pausedPosition = _controller.value.position;
await tester.pumpAndSettle(_playDuration);

// Verify that we stopped playing after the pause.
expect(_controller.value.isPlaying, false);
expect(_controller.value.position, pausedPosition);
},
);

testWidgets('reports buffering status', (WidgetTester tester) async {
await _controller.initialize();
final Completer<void> started = Completer();
final Completer<void> ended = Completer();
bool startedBuffering = false;
bool endedBuffering = false;
_controller.addListener(
() {
if (_controller.value.isBuffering && !startedBuffering) {
startedBuffering = true;
started.complete();
}
if (startedBuffering &&
!_controller.value.isBuffering &&
!endedBuffering) {
endedBuffering = true;
ended.complete();
}
},
);

await _controller.play();
await _controller.seekTo(const Duration(seconds: 5));
await tester.pumpAndSettle(_playDuration);
await _controller.pause();

expect(_controller.value.isPlaying, false);
expect(_controller.value.position,
(Duration position) => position > const Duration(seconds: 0));

await started;
expect(startedBuffering, true);

await ended;
expect(endedBuffering, true);
});

testWidgets('can show video player', (WidgetTester tester) async {
Future<bool> started() async {
await _controller.initialize();
await _controller.play();
return true;
}

await tester.pumpWidget(Material(
elevation: 0,
child: Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: FutureBuilder<bool>(
future: started(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
if (snapshot.data == true) {
return AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller),
);
} else {
return const Text('waiting for video to load');
}
},
),
),
),
));

await tester.pumpAndSettle(_playDuration);
expect(_controller.value.isPlaying, true);
});
});
}
Loading