From c48e5bb63ea6d9a9618928802a10b8def04f7993 Mon Sep 17 00:00:00 2001 From: ArtisanLRO Date: Sun, 25 Jul 2021 23:03:50 +1000 Subject: [PATCH] Fix #39 issue with audio tracks and remove auto-rotation --- README.md | 6 ++--- chewie/lib/src/material_controls.dart | 32 ++++++++++++++++++--------- lib/dictionary.dart | 4 ++-- lib/player.dart | 7 +++--- lib/util.dart | 5 ++++- pubspec.lock | 21 ++++++------------ pubspec.yaml | 5 +++-- 7 files changed, 43 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 015559105..d6796a1b9 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@

A mobile video player, reader assistant and card creation toolkit tailored for language learners.

Latest GitHub Release:
-0.25.9-beta ๐Ÿ‡ฏ๐Ÿ‡ต โ†’ ๐Ÿ‡ฌ๐Ÿ‡ง
+0.25.10-beta ๐Ÿ‡ฏ๐Ÿ‡ต โ†’ ๐Ÿ‡ฌ๐Ÿ‡ง
0.16.8-beta ๐Ÿ‡ฐ๐Ÿ‡ท โ†’ ๐Ÿ‡ฌ๐Ÿ‡ง

@@ -34,7 +34,7 @@ 0.22 ยท 0.23 ยท 0.24 ยท - 0.25 + 0.25

# ๐Ÿ“š Uninterrupted language immersion at your fingertips @@ -58,7 +58,7 @@ # โš•๏ธ Current state of the project -**jidoujisho is still in active development.** Built for the Japanese language learning community, the application is free and open source software, and is available to download here on GitHub. Current features planned on the roadmap are listed below, but as of now there is no estimate on any updates. +**jidoujisho is still in development, and is currently in hiatus. The project will receive fixes to critical bugs and issues. Rollout of new features will resume in time.** Built for the Japanese language learning community, the application is free and open source software, and is available to download here on GitHub. Current features planned on the roadmap are listed below, but as of now there is no estimate on any updates. Please note that the development of the app switches between changes being implemented and being left alone for daily use. Update frequency may depend on the gravity of any issues that arise. **Hiatuses provide practical insight on usage and where development should go next.** diff --git a/chewie/lib/src/material_controls.dart b/chewie/lib/src/material_controls.dart index 5bc97e463..7a3bfde0e 100755 --- a/chewie/lib/src/material_controls.dart +++ b/chewie/lib/src/material_controls.dart @@ -761,7 +761,7 @@ class _MaterialControlsState extends State return GestureDetector( onTap: () async { chewieController.currentAudioTrack.value = - await controller.getAudioTrack() - 1; + await controller.getAudioTrack(); _hideTimer?.cancel(); @@ -770,10 +770,8 @@ class _MaterialControlsState extends State final List autoSubtitleTrackNames = []; if (chewieController.playerMode != JidoujishoPlayerMode.youtubeStream) { - final audioTracks = await controller.getAudioTracks(); final subtitleTracks = await controller.getSpuTracks(); - audioTracks.forEach((index, name) => audioTrackNames.add(name)); subtitleTracks.forEach((index, name) { if (subtitleTrackNames.length < chewieController.internalSubs.length) { @@ -786,20 +784,30 @@ class _MaterialControlsState extends State } else { autoSubtitleTrackNames.add("YouTube - [Automatic] - [Japanese]"); } - audioTrackNames - .add("YouTube - ${chewieController.streamData.audioMetadata}"); } final List options = []; - for (int i = 0; i < audioTrackNames.length; i++) { + final audioTracks = await controller.getAudioTracks(); + if (chewieController.streamData == null) { + audioTracks.forEach((index, name) { + options.add( + SubtitleAudioMenuOption( + type: SubtitleAudioMenuOptionType.audioTrack, + callbackIndex: index, + metadata: name, + ), + ); + }); + } else { options.add( SubtitleAudioMenuOption( - type: SubtitleAudioMenuOptionType.audioTrack, - callbackIndex: i, - metadata: audioTrackNames[i], - ), + type: SubtitleAudioMenuOptionType.audioTrack, + callbackIndex: 0, + metadata: + "YouTube - ${chewieController.streamData.audioMetadata}"), ); } + if (chewieController.playerMode != JidoujishoPlayerMode.networkStream) { for (int i = 0; i < subtitleTrackNames.length; i++) { options.add( @@ -864,7 +872,9 @@ class _MaterialControlsState extends State switch (chosenOption.type) { case SubtitleAudioMenuOptionType.audioTrack: - await controller.setAudioTrack(chosenOption.callbackIndex + 1); + if (chewieController.streamData == null) { + await controller.setAudioTrack(chosenOption.callbackIndex); + } break; case SubtitleAudioMenuOptionType.embeddedSubtitle: case SubtitleAudioMenuOptionType.autoSubtitle: diff --git a/lib/dictionary.dart b/lib/dictionary.dart index 2ee712929..cd97932d0 100644 --- a/lib/dictionary.dart +++ b/lib/dictionary.dart @@ -8,8 +8,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_archive/flutter_archive.dart'; import 'package:fluttertoast/fluttertoast.dart'; -//import 'package:gx_file_picker/gx_file_picker.dart'; -import 'package:file_picker/file_picker.dart'; +import 'package:gx_file_picker/gx_file_picker.dart'; +//import 'package:file_picker/file_picker.dart'; import 'package:html/parser.dart' as parser; import 'package:http/http.dart' as http; import 'package:jidoujisho/globals.dart'; diff --git a/lib/player.dart b/lib/player.dart index c5bf7608e..8249a7d70 100644 --- a/lib/player.dart +++ b/lib/player.dart @@ -6,8 +6,8 @@ import 'package:audio_service/audio_service.dart'; import 'package:chewie/chewie.dart'; import 'package:clipboard_monitor/clipboard_monitor.dart'; import 'package:external_app_launcher/external_app_launcher.dart'; -//import 'package:gx_file_picker/gx_file_picker.dart'; -import 'package:file_picker/file_picker.dart'; +import 'package:gx_file_picker/gx_file_picker.dart'; +//import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_vlc_player/flutter_vlc_player.dart'; @@ -86,7 +86,6 @@ class JidoujishoPlayerState extends State { @override void dispose() { super.dispose(); - unlockLandscape(); } Widget localPlayer(BuildContext context, String url, int initialPosition) { @@ -153,7 +152,7 @@ class JidoujishoPlayerState extends State { String unsanitized = ""; if (externalSubs != null) { unsanitized = externalSubs.readAsStringSync(); - } else if (internalSubs.isNotEmpty) { + } else if (internalSubs != null && internalSubs.isNotEmpty) { unsanitized = internalSubs.first.readAsStringSync(); } String defaultSubtitles = sanitizeSrtNewlines(unsanitized); diff --git a/lib/util.dart b/lib/util.dart index fdd8ed388..f4c0729e1 100644 --- a/lib/util.dart +++ b/lib/util.dart @@ -39,7 +39,10 @@ void unlockLandscape() { void lockLandscape() { Wakelock.enable(); - AutoOrientation.landscapeAutoMode(forceSensor: true); + SystemChrome.setPreferredOrientations([ + DeviceOrientation.landscapeLeft, + DeviceOrientation.landscapeRight, + ]); SystemChrome.setEnabledSystemUIOverlays([]); } diff --git a/pubspec.lock b/pubspec.lock index d1e875b43..cca8b8132 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -311,20 +311,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "6.1.2" - file_picker: - dependency: "direct main" - description: - name: file_picker - url: "https://pub.dartlang.org" - source: hosted - version: "1.13.3" - file_picker_platform_interface: - dependency: transitive - description: - name: file_picker_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" fixnum: dependency: transitive description: @@ -477,6 +463,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + gx_file_picker: + dependency: "direct main" + description: + name: gx_file_picker + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.0+2" html: dependency: "direct overridden" description: diff --git a/pubspec.yaml b/pubspec.yaml index ff9bde5d6..47a8a53ee 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: jidoujisho description: A mobile video player tailored for Japanese language learners. publish_to: none -version: 0.25.9+73 +version: 0.25.10+74 environment: sdk: ">=2.7.0 <3.0.0" @@ -26,7 +26,8 @@ dependencies: device_info_plus: ext_storage: external_app_launcher: - file_picker: 1.13.3 + #file_picker: 1.13.3 + gx_file_picker: flutter_archive: 3.0.0 flutter_absolute_path: flutter_cache_manager: