@basmilius/apple-devices 0.9.4 → 0.9.6

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.
Files changed (2) hide show
  1. package/dist/index.mjs +8 -6
  2. package/package.json +5 -5
package/dist/index.mjs CHANGED
@@ -1967,13 +1967,15 @@ var Client = class {
1967
1967
  return this.#playbackState === Proto.PlaybackState_Enum.Playing;
1968
1968
  }
1969
1969
  get elapsedTime() {
1970
- const npi = this.#nowPlayingInfo;
1971
1970
  const meta = this.currentItemMetadata;
1972
- const elapsed = npi?.elapsedTime || meta?.elapsedTime || 0;
1973
- const rate = npi?.playbackRate ?? meta?.playbackRate ?? 0;
1974
- const timestamp = npi?.timestamp || meta?.elapsedTimeTimestamp || 0;
1975
- if (rate === 0 || timestamp === 0) return elapsed;
1976
- return elapsed + (Date.now() / 1e3 - timestamp) * rate;
1971
+ const npi = this.#nowPlayingInfo;
1972
+ const elapsedTimestamp = meta?.elapsedTimeTimestamp || 0;
1973
+ const elapsed = meta?.elapsedTime || npi?.elapsedTime || 0;
1974
+ if (!elapsedTimestamp) return elapsed;
1975
+ if ((meta?.playbackRate ?? npi?.playbackRate ?? 0) === 0 || !this.isPlaying) return elapsed;
1976
+ const timestampUnix = elapsedTimestamp + 978307200;
1977
+ const diff = Date.now() / 1e3 - timestampUnix;
1978
+ return Math.max(0, elapsed + diff);
1977
1979
  }
1978
1980
  get currentItem() {
1979
1981
  if (!this.#playbackQueue || this.#playbackQueue.contentItems.length === 0) return null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@basmilius/apple-devices",
3
3
  "description": "Exposes various Apple devices to connect with either AirPlay or Companion Link.",
4
- "version": "0.9.4",
4
+ "version": "0.9.6",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -49,10 +49,10 @@
49
49
  }
50
50
  },
51
51
  "dependencies": {
52
- "@basmilius/apple-airplay": "0.9.4",
53
- "@basmilius/apple-common": "0.9.4",
54
- "@basmilius/apple-companion-link": "0.9.4",
55
- "@basmilius/apple-encoding": "0.9.4"
52
+ "@basmilius/apple-airplay": "0.9.6",
53
+ "@basmilius/apple-common": "0.9.6",
54
+ "@basmilius/apple-companion-link": "0.9.6",
55
+ "@basmilius/apple-encoding": "0.9.6"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/bun": "^1.3.9",