Skip to content

Commit

Permalink
Merge pull request #507 from lamarios/fix/proxy-not-working-for-non-d…
Browse files Browse the repository at this point in the history
…ash-videos

fix #504
  • Loading branch information
lamarios authored Mar 23, 2024
2 parents 0d5d554 + bc9f3d1 commit cc7a2c1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/player/states/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ part 'video_player.freezed.dart';

final log = Logger('VideoPlayer');

final _googleCdnRegex = RegExp(r'https://(.+)googlevideo.com/');

class VideoPlayerCubit extends MediaPlayerCubit<VideoPlayerState> {
BetterPlayerController? videoController;
final SettingsCubit settings;
Expand Down Expand Up @@ -273,6 +275,13 @@ class VideoPlayerCubit extends MediaPlayerCubit<VideoPlayerState> {
newState.copyWith(selectedNonDashTrack: formatStream.resolution);
}

// somehow invidious is sending google url even when using local proxy when not using dash
if (!isUsingDash() && service.useProxy()) {
// we replace google's cdn by invidious server url.
videoUrl = videoUrl.replaceFirst(_googleCdnRegex,
'${(await db.getCurrentlySelectedServer()).url}/');
}

log.info(
'Playing url (dash ${isUsingDash()}, hasHls ? ${newState.video!.hlsUrl != null}) $videoUrl');

Expand Down

0 comments on commit cc7a2c1

Please sign in to comment.