forked from media-kit/media-kit
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request media-kit#364 from media-kit/feat/re-android-waitu…
…ntilfirstframerendered feat(android): re-implement `waitUntilFirstFrameRenderedNotify` API (media-kit#349)
- Loading branch information
Showing
8 changed files
with
524 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/// This file is a part of media_kit (https://github.com/media-kit/media-kit). | ||
/// | ||
/// Copyright © 2021 & onwards, Hitesh Kumar Saini <[email protected]>. | ||
/// All rights reserved. | ||
/// Use of this source code is governed by MIT license that can be found in the LICENSE file. | ||
import 'dart:io'; | ||
import 'dart:convert'; | ||
import 'dart:isolate'; | ||
import 'dart:collection'; | ||
import 'package:path/path.dart'; | ||
import 'package:safe_local_storage/safe_local_storage.dart'; | ||
|
||
import 'package:media_kit/src/player/native/utils/asset_loader.dart'; | ||
|
||
/// {@template find_packages} | ||
/// | ||
/// FindPackages | ||
/// ------------ | ||
/// | ||
/// A utility check whether required package:media_kit_*** packages are available or not. | ||
/// | ||
/// {@endtemplate} | ||
abstract class FindPackages { | ||
static void ensureInitialized() { | ||
if (!_initialized) { | ||
_initialized = true; | ||
Isolate.spawn( | ||
_ensureInitialized, | ||
null, | ||
); | ||
} | ||
} | ||
|
||
static Future<void> _ensureInitialized(_) async { | ||
final script = basename(Platform.script.toFilePath()); | ||
final executable = basename(Platform.resolvedExecutable); | ||
|
||
final asset = await File(AssetLoader.load('NOTICES.Z')).readAsBytes_(); | ||
if (asset != null) { | ||
final content = utf8.decode(gzip.decode(asset)); | ||
final elements = content.split('-' * 80); | ||
final names = HashSet<String>(); | ||
|
||
for (final element in elements) { | ||
bool found = false; | ||
final current = HashSet<String>(); | ||
final lines = element.split('\n'); | ||
for (final line in lines) { | ||
if (line.isNotEmpty) { | ||
current.add(line); | ||
found = true; | ||
} else if (found && line.isEmpty) { | ||
break; | ||
} | ||
} | ||
names.addAll(current); | ||
} | ||
|
||
final supported = HashSet<String>.of( | ||
[ | ||
'media_kit', | ||
'media_kit_video', | ||
'media_kit_native_event_loop', | ||
], | ||
); | ||
|
||
bool success = true; | ||
|
||
for (final name in names) { | ||
if (!script.contains(name) && !executable.contains(name)) { | ||
if (name.contains('media_kit')) { | ||
if (!name.startsWith('media_kit') && !supported.contains(name)) { | ||
success = false; | ||
break; | ||
} | ||
} else if (name.contains('video') && name.contains('player')) { | ||
if (!name.contains('video_player') && !name.contains('-')) { | ||
success = false; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (!success) { | ||
exit(0); | ||
} | ||
} | ||
} | ||
|
||
static bool _initialized = false; | ||
} |
Oops, something went wrong.