Skip to content

Commit

Permalink
Merge pull request #282 from lamarios/feature/fix-live-streams
Browse files Browse the repository at this point in the history
fix issue that makes live streams not playable
  • Loading branch information
lamarios authored Aug 19, 2023
2 parents e081aea + 7d9dcc8 commit 66d8d1d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
1 change: 1 addition & 0 deletions lib/player/states/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ class PlayerCubit extends Cubit<PlayerState> {
}

playNext() {

if (state.videos.isNotEmpty || state.offlineVideos.isNotEmpty) {
var state = this.state.copyWith();
var listToUpdate = state.videos.isNotEmpty ? state.videos : state.offlineVideos;
Expand Down
7 changes: 4 additions & 3 deletions lib/player/states/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,14 @@ class VideoPlayerCubit extends MediaPlayerCubit<VideoPlayerState> {
Map<String, String> resolutions = {};

bool isHls = state.video!.hlsUrl != null;
var formatStream = state.video!.formatStreams[state.video!.formatStreams.length - 1];

var formatStream = isHls ? null : state.video!.formatStreams[state.video!.formatStreams.length - 1];
String videoUrl = isHls
? '${state.video!.hlsUrl!}${service.useProxy() ? '?local=true' : ''}'
: state.useDash
? '${state.video!.dashUrl}${service.useProxy() ? '?local=true' : ''}'
: formatStream.url;
if (!state.useDash) {
: formatStream?.url ?? '';
if (!state.useDash && formatStream != null) {
state.selectedNonDashTrack = formatStream.resolution;
}

Expand Down
40 changes: 21 additions & 19 deletions lib/player/views/components/mini_player_progress.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,27 @@ class MiniPlayerProgress extends StatelessWidget {
buildWhen: (previous, current) => previous.position != current.position,
builder: (context, _) {
var player = context.read<PlayerCubit>();
return Container(
alignment: Alignment.centerLeft,
width: double.infinity,
height: 2,
decoration: BoxDecoration(
color: colors.secondaryContainer,
borderRadius: BorderRadius.circular(20),
),
child: AnimatedFractionallySizedBox(
widthFactor: _.position.inMilliseconds / player.duration.inMilliseconds,
heightFactor: 1,
duration: const Duration(milliseconds: 750),
curve: Curves.easeInOutQuad,
child: Container(
decoration: BoxDecoration(
color: colors.primary,
borderRadius: BorderRadius.circular(20),
),
)));
return !(player.state.currentlyPlaying?.liveNow ?? false)
? Container(
alignment: Alignment.centerLeft,
width: double.infinity,
height: 2,
decoration: BoxDecoration(
color: colors.secondaryContainer,
borderRadius: BorderRadius.circular(20),
),
child: AnimatedFractionallySizedBox(
widthFactor: _.position.inMilliseconds / player.duration.inMilliseconds,
heightFactor: 1,
duration: const Duration(milliseconds: 750),
curve: Curves.easeInOutQuad,
child: Container(
decoration: BoxDecoration(
color: colors.primary,
borderRadius: BorderRadius.circular(20),
),
)))
: const SizedBox.shrink();
},
);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/player/views/components/player_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class PlayerControls extends StatelessWidget {

showOptionMenu(BuildContext context, PlayerControlsState controls, MediaPlayerCubit pc) {
var locals = AppLocalizations.of(context)!;

var player = context.read<PlayerCubit>();
var videoTracks = pc.getVideoTracks();
var audioTracks = pc.getAudioTracks();
var subtitles = pc.getSubtitles();
Expand Down Expand Up @@ -149,7 +149,7 @@ class PlayerControls extends StatelessWidget {
leading: const Icon(Icons.music_note),
title: Text(locals.audio),
),
if (pc.hasDashToggle())
if (pc.hasDashToggle() && !(player.state.currentlyPlaying?.liveNow ?? false))
ListTile(
onTap: () {
Navigator.of(context).pop();
Expand Down Expand Up @@ -240,7 +240,7 @@ class PlayerControls extends StatelessWidget {
}
],
),
Padding(
if(!(player.state.currentlyPlaying?.liveNow ?? false)) Padding(
padding: const EdgeInsets.only(top: 0.0, right: 8),
child: Row(
children: [
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.14.0+4016
version: 1.14.1+4017

environment:
sdk: '>=3.0.0 <4.0.0'
Expand Down

0 comments on commit 66d8d1d

Please sign in to comment.