Skip to content

Commit

Permalink
fix: if event is downloaded, use the download path
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa committed Aug 14, 2023
1 parent eb3d82c commit 792f357
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/widgets/events_timeline/desktop/timeline_sidebar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class _TimelineSidebarState extends State<TimelineSidebar> {
widget.timeline.add([
state.realDevices.entries
.firstWhere((e) => e.key == device)
.buildTimelineTile(),
.buildTimelineTile(context),
]);
}
}
Expand Down Expand Up @@ -202,7 +202,7 @@ class _TimelineSidebarState extends State<TimelineSidebar> {
widget.timeline.add([
state.realDevices.entries
.firstWhere((e) => e.key == device)
.buildTimelineTile(),
.buildTimelineTile(context),
]);
}
setState(() {});
Expand Down
17 changes: 14 additions & 3 deletions lib/widgets/events_timeline/events_playback.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import 'dart:io';

import 'package:bluecherry_client/api/api.dart';
import 'package:bluecherry_client/models/device.dart';
import 'package:bluecherry_client/models/event.dart';
import 'package:bluecherry_client/providers/downloads_provider.dart';
import 'package:bluecherry_client/providers/home_provider.dart';
import 'package:bluecherry_client/providers/server_provider.dart';
import 'package:bluecherry_client/utils/constants.dart';
Expand Down Expand Up @@ -172,7 +175,7 @@ class _EventsPlaybackState extends State<EventsPlayback> {

final parsedTiles = devices.entries
.where((e) => e.value.isNotEmpty)
.map((e) => e.buildTimelineTile());
.map((e) => e.buildTimelineTile(context));

home.notLoading(UnityLoadingReason.fetchingEventsPlayback);

Expand Down Expand Up @@ -253,18 +256,26 @@ class _EventsPlaybackState extends State<EventsPlayback> {
}

extension DevicesMapExtension on MapEntry<Device, List<Event>> {
TimelineTile buildTimelineTile() {
TimelineTile buildTimelineTile(BuildContext context) {
final device = key;
final events = value;
debugPrint('Loaded ${events.length} events for $device');

return TimelineTile(
device: device,
events: events.map((event) {
final downloads = context.read<DownloadsManager>();
final mediaUrl = downloads.isEventDownloaded(event.id)
? Uri.file(
downloads.getDownloadedPathForEvent(event.id),
windows: Platform.isWindows,
).toString()
: event.mediaURL!.toString();

return TimelineEvent(
startTime: event.published,
duration: event.duration,
videoUrl: event.mediaURL!.toString(),
videoUrl: mediaUrl,
event: event,
);
}).toList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ class _TimelineDeviceViewState extends State<TimelineDeviceView> {
}

return UnityVideoView(
heroTag: currentEvent!.event.mediaURL,
heroTag: currentEvent!.videoUrl,
player: tile.videoController,
paneBuilder: !kDebugMode
? null
Expand Down

0 comments on commit 792f357

Please sign in to comment.