Skip to content

Commit

Permalink
Fix #39 issue with audio tracks and remove auto-rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
arianneorpilla committed Jul 25, 2021
1 parent 55f8176 commit c48e5bb
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 37 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<p align="center">A mobile video player, reader assistant and card creation toolkit tailored for language learners.</p>

<p align="center" style="margin:0"><b>Latest GitHub Release:<br>
<a href="https://github.com/lrorpilla/jidoujisho/releases/tag/0.25.9-beta">0.25.9-beta 🇯🇵 → 🇬🇧</a><br>
<a href="https://github.com/lrorpilla/jidoujisho/releases/tag/0.25.10-beta">0.25.10-beta 🇯🇵 → 🇬🇧</a><br>
<a href="https://github.com/lrorpilla/jidoujisho/releases/tag/0.16.8-beta-kren">0.16.8-beta 🇰🇷 → 🇬🇧</a></b><br>
</p>

Expand All @@ -34,7 +34,7 @@
<a href="https://github.com/lrorpilla/jidoujisho/releases/tag/0.22.1-beta">0.22</a> ·
<a href="https://github.com/lrorpilla/jidoujisho/releases/tag/0.23.2-beta">0.23</a> ·
<a href="https://github.com/lrorpilla/jidoujisho/releases/tag/0.24.5-beta">0.24</a> ·
<a href="https://github.com/lrorpilla/jidoujisho/releases/tag/0.25.9-beta">0.25</a>
<a href="https://github.com/lrorpilla/jidoujisho/releases/tag/0.25.10-beta">0.25</a>
</b></p>

# 📚 Uninterrupted language immersion at your fingertips
Expand All @@ -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 <b><a href="https://github.com/lrorpilla/jidoujisho/releases">available to download here on GitHub.</a></b> 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 <b><a href="https://github.com/lrorpilla/jidoujisho/releases">available to download here on GitHub.</a></b> 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.**

Expand Down
32 changes: 21 additions & 11 deletions chewie/lib/src/material_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ class _MaterialControlsState extends State<MaterialControls>
return GestureDetector(
onTap: () async {
chewieController.currentAudioTrack.value =
await controller.getAudioTrack() - 1;
await controller.getAudioTrack();

_hideTimer?.cancel();

Expand All @@ -770,10 +770,8 @@ class _MaterialControlsState extends State<MaterialControls>
final List<String> 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) {
Expand All @@ -786,20 +784,30 @@ class _MaterialControlsState extends State<MaterialControls>
} else {
autoSubtitleTrackNames.add("YouTube - [Automatic] - [Japanese]");
}
audioTrackNames
.add("YouTube - ${chewieController.streamData.audioMetadata}");
}

final List<SubtitleAudioMenuOption> 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(
Expand Down Expand Up @@ -864,7 +872,9 @@ class _MaterialControlsState extends State<MaterialControls>

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:
Expand Down
4 changes: 2 additions & 2 deletions lib/dictionary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
7 changes: 3 additions & 4 deletions lib/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -86,7 +86,6 @@ class JidoujishoPlayerState extends State<JidoujishoPlayer> {
@override
void dispose() {
super.dispose();
unlockLandscape();
}

Widget localPlayer(BuildContext context, String url, int initialPosition) {
Expand Down Expand Up @@ -153,7 +152,7 @@ class JidoujishoPlayerState extends State<JidoujishoPlayer> {
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);
Expand Down
5 changes: 4 additions & 1 deletion lib/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ void unlockLandscape() {

void lockLandscape() {
Wakelock.enable();
AutoOrientation.landscapeAutoMode(forceSensor: true);
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
SystemChrome.setEnabledSystemUIOverlays([]);
}

Expand Down
21 changes: 7 additions & 14 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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:
Expand Down

0 comments on commit c48e5bb

Please sign in to comment.