Skip to content

Commit 96aa439

Browse files
committed
[video_player_avplay] Add check platform and api version
Add a step to the initialization phase that compares the API version of the app using avplay with the version of TizenOS. This prevents TPKs built with avplay from running on TizenOS versions for which they are not intended. related issue: #786
1 parent 9398e21 commit 96aa439

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

packages/video_player_avplay/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.11
2+
3+
* Add check platform and api version.
4+
15
## 0.5.10
26

37
* Add setDisplayRotate API

packages/video_player_avplay/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ To use this package, add `video_player_avplay` as a dependency in your `pubspec.
1212

1313
```yaml
1414
dependencies:
15-
video_player_avplay: ^0.5.10
15+
video_player_avplay: ^0.5.11
1616
```
1717
1818
Then you can import `video_player_avplay` in your Dart code:

packages/video_player_avplay/lib/video_player.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import 'dart:async';
77
import 'dart:io';
88

9+
import 'package:device_info_plus_tizen/device_info_plus_tizen.dart';
910
import 'package:flutter/foundation.dart';
1011
import 'package:flutter/material.dart';
1112
import 'package:flutter/services.dart';
13+
import 'package:flutter_tizen/flutter_tizen.dart';
1214

1315
import 'src/closed_caption_file.dart';
1416
import 'src/drm_configs.dart';
@@ -369,8 +371,24 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
369371
final MethodChannel _channel =
370372
const MethodChannel('dev.flutter.videoplayer.drm');
371373

374+
Future<void> _checkPlatformAndApiVersion() async {
375+
final DeviceInfoPluginTizen deviceInfoPlugin = DeviceInfoPluginTizen();
376+
final TizenDeviceInfo deviceInfo = await deviceInfoPlugin.tizenInfo;
377+
378+
if (deviceInfo.platformVersion != apiVersion) {
379+
throw Exception(
380+
'The current TizenOS version(${deviceInfo.platformVersion}) '
381+
'and the app API version($apiVersion) are different. '
382+
'The avplay plugin does not guarantee compatibility with '
383+
'other versions. Therefore, please set the "api-version" '
384+
'in tizen-manifest.xml to match the TizenOS version and rebuild.');
385+
}
386+
}
387+
372388
/// Attempts to open the given [dataSource] and load metadata about the video.
373389
Future<void> initialize() async {
390+
await _checkPlatformAndApiVersion();
391+
374392
final bool allowBackgroundPlayback =
375393
videoPlayerOptions?.allowBackgroundPlayback ?? false;
376394
if (!allowBackgroundPlayback) {

packages/video_player_avplay/pubspec.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: video_player_avplay
22
description: Flutter plugin for displaying inline video on Tizen TV devices.
33
homepage: https://github.com/flutter-tizen/plugins
44
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/video_player_avplay
5-
version: 0.5.10
5+
version: 0.5.11
66

77
environment:
88
sdk: ">=3.1.0 <4.0.0"
@@ -16,8 +16,10 @@ flutter:
1616
fileName: video_player_tizen_plugin.h
1717

1818
dependencies:
19+
device_info_plus_tizen: ^1.2.0
1920
flutter:
2021
sdk: flutter
22+
flutter_tizen: ^0.2.4
2123
html: ^0.15.0
2224
plugin_platform_interface: ^2.1.0
2325

0 commit comments

Comments
 (0)