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

Experimental support for video player #1081

Merged
merged 17 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Setting to use colorized usernames - contribution from @ggichure.
- Show the number of new comments a read post has received since last visited
- Added ability to mark read on scroll - contribution from @Fmstrat
- Added barebones support for video players. Youtube and video codecs - contribution from @ggichure.

## Changed
- Small UI adjustments for account switcher
Expand Down
2 changes: 1 addition & 1 deletion android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken

##---------------End: proguard configuration for Gson ----------
##---------------End: proguard configuration for Gson ----------
7 changes: 7 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.VIBRATE" />

<uses-permission android:minSdkVersion="34" android:name="android.permission.USE_EXACT_ALARM" />

<!-- The tools:replace line is needed by background_fetch -->
<!-- requestLegacyExternalStorage is required for saving media to an album in API 29 -->
<application
Expand All @@ -26,7 +28,12 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:resizeableActivity="true">
android:windowSoftInputMode="adjustResize">
<!--Allowing support for multi windows (split-screen mode) & picture-in-picture mode -->
<meta-data
android:name="android.allow_multiple_resumed_activities"
android:value="true" />
<!-- support sharing images -->
<intent-filter
android:label="@string/create_post">
Expand Down
1 change: 1 addition & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
Expand Down
3 changes: 1 addition & 2 deletions lib/community/widgets/post_card_view_comfortable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class PostCardViewComfortable extends StatelessWidget {

final Color? readColor = indicateRead && postViewMedia.postView.read ? theme.textTheme.bodyMedium?.color?.withOpacity(0.45) : theme.textTheme.bodyMedium?.color?.withOpacity(0.90);

var mediaView = MediaView(
Widget mediaView = MediaView(
scrapeMissingPreviews: state.scrapeMissingPreviews,
postViewMedia: postViewMedia,
showFullHeightImages: showFullHeightImages,
Expand All @@ -93,7 +93,6 @@ class PostCardViewComfortable extends StatelessWidget {
navigateToPost: navigateToPost,
read: indicateRead && postViewMedia.postView.read,
);

final bool useSaveButton = state.showSaveAction;
final double textScaleFactor = state.titleFontSizeScale.textScaleFactor;

Expand Down
1 change: 1 addition & 0 deletions lib/core/enums/internet_connection_type.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enum InternetConnectionType { wifi, mobile, unknown }
19 changes: 16 additions & 3 deletions lib/core/enums/local_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ enum LocalSettingsCategories {
account('Account'),
about('About'),
debug('Debug'),
theming('Theming');
theming('Theming'),
videoPlayer('Video Player');

final String value;

Expand Down Expand Up @@ -45,7 +46,8 @@ enum LocalSettingsSubCategories {
theme('Theme'),
sidebar('Sidebar'),
cardView('cardView'),
navigation('navigation');
navigation('navigation'),
videoPlayer('videoPlayer');

final String value;

Expand Down Expand Up @@ -305,7 +307,13 @@ enum LocalSettings {
// This setting exists purely to save/load the user's selected advanced share options
advancedShareOptions(name: 'advanced_share_options', key: ''),
// import export settings
importExportSettings(name: 'import_export_settings', key: 'importExportSettings', category: LocalSettingsCategories.general, subCategory: LocalSettingsSubCategories.importExportSettings);
importExportSettings(name: 'import_export_settings', key: 'importExportSettings', category: LocalSettingsCategories.general, subCategory: LocalSettingsSubCategories.importExportSettings),
// video player
videoAutoMute(name: 'auto_mute_videos', key: 'videoAutoMute', category: LocalSettingsCategories.videoPlayer, subCategory: LocalSettingsSubCategories.videoPlayer),
videoDefaultPlaybackSpeed(name: 'video_default_playback_speed', key: 'videoDefaultPlaybackSpeed', category: LocalSettingsCategories.videoPlayer, subCategory: LocalSettingsSubCategories.videoPlayer),
videoAutoFullscreen(name: 'video_auto_fullscreen', key: 'videoAutoFullscreen', category: LocalSettingsCategories.videoPlayer, subCategory: LocalSettingsSubCategories.videoPlayer),
videoAutoLoop(name: 'video_auto_loop', key: '', category: LocalSettingsCategories.videoPlayer, subCategory: LocalSettingsSubCategories.videoPlayer),
videoAutoPlay(name: 'video_auto_play', key: '', category: LocalSettingsCategories.videoPlayer, subCategory: LocalSettingsSubCategories.videoPlayer);

const LocalSettings({
required this.name,
Expand Down Expand Up @@ -455,6 +463,11 @@ extension LocalizationExt on AppLocalizations {
'profiles': profiles,
'animations': animations,
'discussionLanguages': discussionLanguages,
'videoAutoMute': videoAutoMute,
'videoAutoFullscreen': videoAutoFullscreen,
'videoAutoLoop': videoAutoLoop,
'videoAutoPlay': videoAutoPlay,
'videoDefaultPlaybackSpeed': videoDefaultPlaybackSpeed,
};

if (localizationMap.containsKey(key)) {
Expand Down
11 changes: 11 additions & 0 deletions lib/core/enums/video_auto_play.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
enum VideoAutoPlay {
never(label: 'Never'),
always(label: 'Always'),
onWifi(label: 'On Wifi');

const VideoAutoPlay({
required this.label,
});

final String label;
}
16 changes: 16 additions & 0 deletions lib/core/enums/video_playback_speed.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
enum VideoPlayBackSpeed {
pointTow5x(label: '0.25x'),
point5x(label: '0.5x'),
pointSeven5x(label: '0.75x'),
normal(label: '1'),
onePointTwo5x(label: '1.25x'),
onePoint5x(label: '1.5x'),
onePointSeven5x(label: '1.75x'),
twoX(label: '2x');

const VideoPlayBackSpeed({
required this.label,
});

final String label;
}
30 changes: 30 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
},
"alreadyPostedTo": "Already posted to",
"@alreadyPostedTo": {},
"always": "Always",
"@always": {},
"andXMore": "and {count} more",
"@andXMore": {},
"animations": "Animations",
Expand Down Expand Up @@ -1137,6 +1139,8 @@
"@nestedCommentIndicatorStyle": {
"description": "Setting for nested comment indicator style"
},
"never": "Never",
"@never": {},
"newComments": "New Comments",
"@newComments": {},
"newPost": "New Post",
Expand Down Expand Up @@ -1245,6 +1249,8 @@
"@old": {},
"on": "on",
"@on": {},
"onWifi": "On Wifi",
"@onWifi": {},
"onlyModsCanPostInCommunity": "Only moderators may post in this community",
"@onlyModsCanPostInCommunity": {},
"open": "Open",
Expand Down Expand Up @@ -2275,6 +2281,30 @@
"@versionNumber": {
"description": "String for describing the current version"
},
"video": "Video",
"@video": {
"description": "String for video "
},
"videoAutoFullscreen": "Auto Fullscreen",
"@videoAutoFullscreen": {
"decription": "Option to always start the video players in landscape"
},
"videoAutoLoop": "Loop Video",
"@videoAutoLoop": {
"description": "Option to always loop a video"
},
"videoAutoMute": "Mute Videos",
"@videoAutoMute": {
"description": "Option to always mute videos"
},
"videoAutoPlay": "Video Autoplay",
"@videoAutoPlay": {
"description": "Option to always autoplay videos"
},
"videoDefaultPlaybackSpeed": "Default Playback Speed",
"@videoDefaultPlaybackSpeed": {
"description": "Option to select the default video playback Speed"
},
"viewAll": "View all",
"@viewAll": {
"description": "A title for viewing all of something (e.g., instances)"
Expand Down
3 changes: 3 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ class _ThunderAppState extends State<ThunderApp> {
BlocProvider(
create: (context) => UserBloc(lemmyClient: LemmyClient.instance),
),
BlocProvider(
create: (context) => NetworkCheckerCubit(),
)
],
child: BlocBuilder<ThemeBloc, ThemeState>(
builder: (context, state) {
Expand Down
13 changes: 12 additions & 1 deletion lib/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import 'package:thunder/settings/pages/general_settings_page.dart';
import 'package:thunder/settings/pages/gesture_settings_page.dart';
import 'package:thunder/settings/pages/post_appearance_settings_page.dart';
import 'package:thunder/settings/pages/theme_settings_page.dart';
import 'package:thunder/settings/pages/video_player_settings.dart';
import 'package:thunder/settings/settings.dart';
import 'package:thunder/thunder/thunder.dart';
import 'package:thunder/user/pages/user_settings_page.dart';
Expand All @@ -35,7 +36,7 @@ final GoRouter router = GoRouter(
GoRoute(
name: 'settings',
path: '/settings',
builder: (BuildContext context, GoRouterState state) => SettingsPage(),
builder: (BuildContext context, GoRouterState state) => const SettingsPage(),
routes: <GoRoute>[
GoRoute(
name: 'general',
Expand Down Expand Up @@ -109,6 +110,16 @@ final GoRouter router = GoRouter(
);
},
),
GoRoute(
name: 'video',
path: 'video',
builder: (context, state) {
return BlocProvider.value(
value: (state.extra! as List)[0] as ThunderBloc,
child: VideoPlayerSettingsPage(settingToHighlight: (state.extra! as List).elementAtOrNull(1) as LocalSettings?),
);
},
),
GoRoute(
name: 'fab',
path: 'fab',
Expand Down
2 changes: 2 additions & 0 deletions lib/settings/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class _SettingsPageState extends State<SettingsPage> {
SettingTopic(title: l10n.filters, icon: Icons.filter_alt_rounded, path: SETTINGS_FILTERS_PAGE),
SettingTopic(title: l10n.appearance, icon: Icons.color_lens_rounded, path: SETTINGS_APPEARANCE_PAGE),
SettingTopic(title: l10n.gestures, icon: Icons.swipe, path: SETTINGS_GESTURES_PAGE),
SettingTopic(title: l10n.video, icon: Icons.video_settings, path: SETTINGS_VIDEO_PAGE),
SettingTopic(title: l10n.floatingActionButton, icon: Icons.settings_applications_rounded, path: SETTINGS_FAB_PAGE),
SettingTopic(title: l10n.accessibility, icon: Icons.accessibility, path: SETTINGS_ACCESSIBILITY_PAGE),
SettingTopic(title: l10n.account(0), icon: Icons.person_rounded, path: SETTINGS_ACCOUNT_PAGE),
Expand Down Expand Up @@ -101,6 +102,7 @@ class _SettingsPageState extends State<SettingsPage> {
LocalSettingsCategories.theming: SETTINGS_APPEARANCE_THEMES_PAGE,
LocalSettingsCategories.debug: SETTINGS_DEBUG_PAGE,
LocalSettingsCategories.about: SETTINGS_ABOUT_PAGE,
LocalSettingsCategories.videoPlayer: SETTINGS_VIDEO_PAGE,
}[localSettings[index].category] ??
SETTINGS_GENERAL_PAGE;

Expand Down
Loading
Loading