Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[video player] Add video_player package #48

Merged
merged 11 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/video_player/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
.dart_tool/

.packages
.pub/

build/
3 changes: 3 additions & 0 deletions packages/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

* Initial release.
26 changes: 26 additions & 0 deletions packages/video_player/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
Copyright (c) 2017 The Chromium Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the names of the copyright holders nor the names of the
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 changes: 39 additions & 0 deletions packages/video_player/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# video_player_tizen

The Tizen implementation of [`video_player`](https://github.com/flutter/plugins/tree/master/packages/video_player).

## Required privileges

To use this plugin in a Tizen application, the mediastorage, externalstorage and internet privileges are required. Add below lines under the `<manifest>` section in your `tizen-manifest.xml` file.

```xml
<privileges>
<privilege>http://tizen.org/privilege/mediastorage</privilege>
<privilege>http://tizen.org/privilege/externalstorage</privilege>
<privilege>http://tizen.org/privilege/internet</privilege>
</privileges>
```

- The mediastorage privilege (`http://tizen.org/privilege/mediastorage`) must be added to play video files located in the internal storage.
- The externalstorage privilege (`http://tizen.org/privilege/externalstorage`) must be added to play video files located in the external storage.
- The internet privilege (`http://tizen.org/privilege/internet`) must be added to play any URLs from network.

For details, see [Security and API Privileges](https://docs.tizen.org/application/dotnet/tutorials/sec-privileges).

## Usage

This package is not an _endorsed_ implementation of `video_player`. Therefore, you have to include `video_player_tizen` alongside `video_player` as dependencies in your `pubspec.yaml` file.

```yaml
dependencies:
video_player: ^1.0.1
video_player_tizen: ^1.0.0
```

Then you can import `video_player` in your Dart code:

```dart
import 'package:video_player/video_player.dart';
```

For how to use the plugin, see https://github.com/flutter/plugins/tree/master/packages/video_player/video_player#usage.
41 changes: 41 additions & 0 deletions packages/video_player/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json
7 changes: 7 additions & 0 deletions packages/video_player/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# video_player_example

Demonstrates how to use the video_player plugin.

## Getting Started

To run this app on your Tizen device, use [flutter-tizen](https://github.com/flutter-tizen/flutter-tizen).
Binary file not shown.
7 changes: 7 additions & 0 deletions packages/video_player/example/assets/bumble_bee_captions.srt
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 ]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 109 additions & 0 deletions packages/video_player/example/integration_test/video_player_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// 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.

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('asset videos', () {
setUp(() {
_controller = VideoPlayerController.asset('assets/Butterfly-209.mp4');
});

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

expect(_controller.value.initialized, true);
expect(_controller.value.position, const Duration(seconds: 0));
expect(_controller.value.isPlaying, false);
expect(_controller.value.duration,
const Duration(seconds: 7, milliseconds: 540));
});

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('test video player view with local asset',
(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();
expect(_controller.value.isPlaying, true);
});
});
}