@axium/client 0.36.2 → 0.36.3

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.
@@ -76,11 +76,13 @@ export class MediaState {
76
76
  e.preventDefault();
77
77
  if (!this.knownDuration) break;
78
78
  this.currentTime = Math.max(0, this.currentTime - 10);
79
+ this.updateAttached();
79
80
  break;
80
81
  case 'ArrowRight':
81
82
  e.preventDefault();
82
83
  if (!this.knownDuration) break;
83
84
  this.currentTime = Math.min(this.knownDuration, this.currentTime + 10);
85
+ this.updateAttached();
84
86
  break;
85
87
  case 'ArrowUp':
86
88
  this.volume = Math.min(1, this.volume + 0.1);
@@ -111,6 +113,18 @@ export class MediaState {
111
113
  /** Seek to a time, clamped to the media's duration when known */
112
114
  seek(time: number) {
113
115
  this.currentTime = this.knownDuration ? Math.min(this.knownDuration, Math.max(0, time)) : Math.max(0, time);
116
+ this.updateAttached();
117
+ }
118
+
119
+ protected isAttached: boolean = false;
120
+
121
+ protected updateAttached() {
122
+ if (!this.isAttached) return;
123
+
124
+ globalThis.navigator?.mediaSession?.setPositionState({
125
+ duration: this.knownDuration,
126
+ position: this.currentTime,
127
+ });
114
128
  }
115
129
 
116
130
  attachToSession(next?: (backward: boolean) => void) {
@@ -118,9 +132,12 @@ export class MediaState {
118
132
 
119
133
  if (!session) return;
120
134
 
135
+ this.isAttached = true;
136
+
121
137
  session.setActionHandler('play', () => {
122
138
  if (this.ended) this.currentTime = 0;
123
139
  this.paused = false;
140
+ this.updateAttached();
124
141
  });
125
142
  session.setActionHandler('pause', () => {
126
143
  this.paused = true;
@@ -128,6 +145,7 @@ export class MediaState {
128
145
  session.setActionHandler('stop', () => {
129
146
  this.paused = true;
130
147
  this.currentTime = 0;
148
+ this.updateAttached();
131
149
  });
132
150
  session.setActionHandler('seekbackward', details => {
133
151
  if (!this.knownDuration) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/client",
3
- "version": "0.36.2",
3
+ "version": "0.36.3",
4
4
  "author": "James Prevett <jp@jamespre.dev>",
5
5
  "funding": {
6
6
  "type": "individual",