streamify-audio 2.1.10 → 2.1.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "streamify-audio",
3
- "version": "2.1.10",
3
+ "version": "2.1.11",
4
4
  "description": "Dual-mode audio library: HTTP streaming proxy + Discord player (Lavalink alternative). Supports YouTube, Spotify, SoundCloud with audio filters.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -252,7 +252,7 @@ class Player extends EventEmitter {
252
252
  });
253
253
  }
254
254
 
255
- async play(track) {
255
+ async play(track, options = {}) {
256
256
  if (this._destroyed) {
257
257
  throw new Error('Player has been destroyed');
258
258
  }
@@ -261,19 +261,22 @@ class Player extends EventEmitter {
261
261
  await this.connect();
262
262
  }
263
263
 
264
+ const startPosition = options.startPosition || options.seek || 0;
265
+
264
266
  if (this.queue.current) {
265
267
  this.queue.add(track, 0);
266
268
  return this.skip();
267
269
  }
268
270
 
269
271
  this.queue.setCurrent(track);
270
- return this._playTrack(track);
272
+ return this._playTrack(track, startPosition);
271
273
  }
272
274
 
273
- async _playTrack(track) {
275
+ async _playTrack(track, startPosition = 0) {
274
276
  if (!track) return;
275
277
 
276
- log.info('PLAYER', `Playing: ${track.title} (${track.id})`);
278
+ const seekInfo = startPosition > 0 ? ` @ ${Math.floor(startPosition / 1000)}s` : '';
279
+ log.info('PLAYER', `Playing: ${track.title} (${track.id})${seekInfo}`);
277
280
  this.emit('trackStart', track);
278
281
 
279
282
  try {
@@ -282,7 +285,7 @@ class Player extends EventEmitter {
282
285
  volume: this._volume
283
286
  };
284
287
 
285
- if (this._prefetchedTrack?.id === track.id && this._prefetchedStream) {
288
+ if (startPosition === 0 && this._prefetchedTrack?.id === track.id && this._prefetchedStream) {
286
289
  log.info('PLAYER', `Using prefetched stream for ${track.id}`);
287
290
  this.stream = this._prefetchedStream;
288
291
  this._prefetchedStream = null;
@@ -292,12 +295,12 @@ class Player extends EventEmitter {
292
295
  this.stream = createStream(track, filtersWithVolume, this.config);
293
296
  }
294
297
 
295
- const resource = await this.stream.create();
298
+ const resource = await this.stream.create(startPosition);
296
299
 
297
300
  this.audioPlayer.play(resource);
298
301
  this._playing = true;
299
302
  this._paused = false;
300
- this._positionMs = 0;
303
+ this._positionMs = startPosition;
301
304
  this._positionTimestamp = Date.now();
302
305
 
303
306
  this._prefetchNext();