@patch-adams/core 1.4.13 → 1.4.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2612,9 +2612,28 @@ function generateLrsBridgeCode(options) {
2612
2612
  };
2613
2613
  }
2614
2614
 
2615
+ /**
2616
+ * Format seconds into MM:SS or HH:MM:SS format
2617
+ */
2618
+ function formatMediaTime(seconds) {
2619
+ if (typeof seconds !== 'number' || isNaN(seconds)) return '0:00';
2620
+ var totalSeconds = Math.floor(seconds);
2621
+ var hours = Math.floor(totalSeconds / 3600);
2622
+ var minutes = Math.floor((totalSeconds % 3600) / 60);
2623
+ var secs = totalSeconds % 60;
2624
+
2625
+ if (hours > 0) {
2626
+ return hours + ':' + (minutes < 10 ? '0' : '') + minutes + ':' + (secs < 10 ? '0' : '') + secs;
2627
+ }
2628
+ return minutes + ':' + (secs < 10 ? '0' : '') + secs;
2629
+ }
2630
+
2615
2631
  /**
2616
2632
  * Build activity object for media (video/audio) with human-readable name
2617
- * Name format: "Video: Title" or "Audio: Title"
2633
+ * Name format varies by action:
2634
+ * - played: "Video: Title (started at 1:23)"
2635
+ * - paused: "Video: Title (paused at 2:45)"
2636
+ * - completed: "Video: Title (completed)"
2618
2637
  */
2619
2638
  function buildMediaActivityObject(mediaInfo) {
2620
2639
  var mediaGuid = mediaInfo.mediaGuid || generateUUID();
@@ -2622,11 +2641,22 @@ function generateLrsBridgeCode(options) {
2622
2641
  var resourceType = mediaInfo.type === 'audio' ? 'Audio' : 'Video';
2623
2642
 
2624
2643
  // Build human-readable display name
2625
- var displayName = mediaInfo.name || '';
2626
- if (!displayName || displayName === 'video' || displayName === 'audio' || displayName === 'Media') {
2627
- displayName = resourceType + ': ' + (mediaInfo.lessonName || 'Media');
2628
- } else {
2629
- displayName = resourceType + ': ' + displayName;
2644
+ var baseName = mediaInfo.name || '';
2645
+ if (!baseName || baseName === 'video' || baseName === 'audio' || baseName === 'Media') {
2646
+ baseName = mediaInfo.lessonName || 'Media';
2647
+ }
2648
+
2649
+ // Add time context based on action
2650
+ var displayName = resourceType + ': ' + baseName;
2651
+ var currentTime = mediaInfo.currentTime || 0;
2652
+ var action = mediaInfo.action;
2653
+
2654
+ if (action === 'play' || action === 'played') {
2655
+ displayName += ' (started at ' + formatMediaTime(currentTime) + ')';
2656
+ } else if (action === 'pause' || action === 'paused') {
2657
+ displayName += ' (paused at ' + formatMediaTime(currentTime) + ')';
2658
+ } else if (action === 'completed' || action === 'complete') {
2659
+ displayName += ' (completed)';
2630
2660
  }
2631
2661
 
2632
2662
  return {
@@ -2951,14 +2981,16 @@ function generateLrsBridgeCode(options) {
2951
2981
  data.action === 'pause' ? 'paused' :
2952
2982
  data.action === 'completed' ? 'completed' : 'played';
2953
2983
 
2954
- // Build activity-specific object with human-readable name
2955
- // e.g., "Video: Introduction" or "Audio: Podcast Episode 1"
2984
+ // Build activity-specific object with human-readable name including time context
2985
+ // e.g., "Video: Introduction (started at 1:23)" or "Audio: Podcast (paused at 2:45)"
2956
2986
  var mediaObject = buildMediaActivityObject({
2957
2987
  type: data.type,
2958
2988
  src: data.src,
2959
2989
  name: data.name,
2960
2990
  duration: data.duration,
2961
- lessonName: lessonInfo.name
2991
+ lessonName: lessonInfo.name,
2992
+ action: data.action,
2993
+ currentTime: data.currentTime
2962
2994
  });
2963
2995
 
2964
2996
  var result = {