Skip to content

Commit

Permalink
core(yt): identify av1 & vp9 streams and present them separate cache …
Browse files Browse the repository at this point in the history
…file
  • Loading branch information
MSOB7YY committed Jul 25, 2024
1 parent 0ad3722 commit dc1d784
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/core/namida_converter_ext.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:youtipie/class/result_wrapper/playlist_result_base.dart';
import 'package:youtipie/class/streams/audio_stream.dart';
import 'package:youtipie/class/streams/video_stream.dart';
import 'package:youtipie/core/enum.dart';
import 'package:youtipie/core/extensions.dart';

import 'package:namida/class/faudiomodel.dart';
import 'package:namida/class/folder.dart';
Expand Down Expand Up @@ -211,7 +212,9 @@ extension CacheGetterAudio on AudioStream {
extension CacheGetterVideo on VideoStream {
String cacheKey(String id) {
final video = this;
return "${id}_${video.qualityLabel}.${video.codecInfo.container}";
var codecIdentifier = codecInfo.codecIdentifierIfCustom();
var suffix = codecIdentifier != null ? '-$codecIdentifier' : '';
return "${id}_${video.qualityLabel}$suffix.${video.codecInfo.container}";
}

String cachePath(String id) {
Expand Down
6 changes: 5 additions & 1 deletion lib/ui/widgets/video_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_volume_controller/flutter_volume_controller.dart' show FlutterVolumeController;
import 'package:youtipie/class/streams/audio_stream.dart';
import 'package:youtipie/class/streams/video_streams_result.dart';
import 'package:youtipie/core/extensions.dart';

import 'package:namida/class/track.dart';
import 'package:namida/class/video.dart';
Expand Down Expand Up @@ -1128,10 +1129,13 @@ class NamidaVideoControlsState extends State<NamidaVideoControls> with TickerPro
}
}

var codecIdentifier = element.codecInfo.codecIdentifierIfCustom();
var codecIdentifierText = codecIdentifier != null ? ' (${codecIdentifier.toUpperCase()})' : '';

return _getQualityChip(
title: element.qualityLabel,
subtitle: " • ${element.sizeInBytes.fileSizeFormatted}",
thirdLine: element.bitrateText(),
thirdLine: "${element.bitrateText()}$codecIdentifierText",
onPlay: (isSelected) {
if (!isSelected || Player.inst.videoPlayerInfo.value?.isInitialized != true) {
Player.inst.onItemPlayYoutubeIDSetQuality(
Expand Down
6 changes: 5 additions & 1 deletion lib/youtube/functions/download_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -543,11 +543,15 @@ Future<void> showDownloadVideoBottomSheet({
return Obx(
() {
final cacheFile = element.getCachedFile(videoId);

var codecIdentifier = element.codecInfo.codecIdentifierIfCustom();
var codecIdentifierText = codecIdentifier != null ? ' (${codecIdentifier.toUpperCase()})' : '';

return getQualityButton(
selected: selectedVideoOnlyStream.valueR == element,
cacheExists: cacheFile != null,
title: "${element.qualityLabel} • ${element.sizeInBytes.fileSizeFormatted}",
subtitle: "${element.codecInfo.container} • ${element.bitrateText()}",
subtitle: "${element.codecInfo.container} • ${element.bitrateText()}$codecIdentifierText",
onTap: () {
selectedVideoOnlyStream.value = element;
onVideoSelectionChanged();
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: namida
description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter
publish_to: "none"
version: 3.6.4-beta+240725225
version: 3.6.5-beta+240725225

environment:
sdk: ">=3.4.0 <4.0.0"
Expand Down

0 comments on commit dc1d784

Please sign in to comment.