nixamp 0.5.8 → 0.5.9

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.
@@ -12,6 +12,14 @@ export interface RemoteTrack {
12
12
  album: string;
13
13
  /** Seconds; 0 when ffprobe could not tell us. */
14
14
  duration: number;
15
+ /**
16
+ * Whether this is a film rather than a song.
17
+ *
18
+ * The server knows, because it has the path; a remote had been guessing, and
19
+ * guessing wrong -- every remote track went to the audio element, so a video
20
+ * a browser could show played its soundtrack over a blank panel.
21
+ */
22
+ video?: boolean;
15
23
  }
16
24
  /** Everything a remote needs to draw the player. */
17
25
  export interface Snapshot {
package/dist/server.d.ts CHANGED
@@ -135,6 +135,7 @@ export interface Engine {
135
135
  stop(): void;
136
136
  }
137
137
  export declare function toRemoteTracks(tracks: Track[]): RemoteTrack[];
138
+ export declare function hasPicture(path: string): boolean;
138
139
  /**
139
140
  * The headless player: the terminal app's engine without the terminal.
140
141
  * One ffmpeg decodes, ffplay makes the sound, and every sample is measured on
package/dist/server.js CHANGED
@@ -269,8 +269,18 @@ export function toRemoteTracks(tracks) {
269
269
  artist: t.artist,
270
270
  album: t.album,
271
271
  duration: t.duration,
272
+ // Said out loud, because a remote cannot see the path and had been sending
273
+ // every track to the audio element -- a film's soundtrack over a blank
274
+ // panel, which is exactly what it looked like.
275
+ ...(hasPicture(t.path) ? { video: true } : {}),
272
276
  }));
273
277
  }
278
+ /** Video containers, as opposed to the songs that are most of a library. */
279
+ const PICTURE = new Set([".mp4", ".mkv", ".avi", ".mov", ".m4v", ".webm", ".mpg", ".mpeg", ".wmv", ".flv"]);
280
+ export function hasPicture(path) {
281
+ const dot = path.lastIndexOf(".");
282
+ return dot > 0 && PICTURE.has(path.slice(dot).toLowerCase());
283
+ }
274
284
  /**
275
285
  * The headless player: the terminal app's engine without the terminal.
276
286
  * One ffmpeg decodes, ffplay makes the sound, and every sample is measured on
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nixamp",
3
- "version": "0.5.8",
3
+ "version": "0.5.9",
4
4
  "description": "It really whips the terminal's ass. A Winamp-shaped audio player for your terminal.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/protocol.ts CHANGED
@@ -13,6 +13,14 @@ export interface RemoteTrack {
13
13
  album: string;
14
14
  /** Seconds; 0 when ffprobe could not tell us. */
15
15
  duration: number;
16
+ /**
17
+ * Whether this is a film rather than a song.
18
+ *
19
+ * The server knows, because it has the path; a remote had been guessing, and
20
+ * guessing wrong -- every remote track went to the audio element, so a video
21
+ * a browser could show played its soundtrack over a blank panel.
22
+ */
23
+ video?: boolean;
16
24
  }
17
25
 
18
26
  /** Everything a remote needs to draw the player. */
package/src/server.ts CHANGED
@@ -391,9 +391,21 @@ export function toRemoteTracks(tracks: Track[]): RemoteTrack[] {
391
391
  artist: t.artist,
392
392
  album: t.album,
393
393
  duration: t.duration,
394
+ // Said out loud, because a remote cannot see the path and had been sending
395
+ // every track to the audio element -- a film's soundtrack over a blank
396
+ // panel, which is exactly what it looked like.
397
+ ...(hasPicture(t.path) ? { video: true } : {}),
394
398
  }));
395
399
  }
396
400
 
401
+ /** Video containers, as opposed to the songs that are most of a library. */
402
+ const PICTURE = new Set([".mp4", ".mkv", ".avi", ".mov", ".m4v", ".webm", ".mpg", ".mpeg", ".wmv", ".flv"]);
403
+
404
+ export function hasPicture(path: string): boolean {
405
+ const dot = path.lastIndexOf(".");
406
+ return dot > 0 && PICTURE.has(path.slice(dot).toLowerCase());
407
+ }
408
+
397
409
  /**
398
410
  * The headless player: the terminal app's engine without the terminal.
399
411
  * One ffmpeg decodes, ffplay makes the sound, and every sample is measured on
@@ -0,0 +1 @@
1
+ import{t as e}from"./index-ABOb54bx.js";var t=3;async function n(n){let{media:r,src:i,isTv:a}=n,{default:o}=await e(async()=>{let{default:e}=await import(`./hls-n74Cnh8A.js`);return{default:e}},[]);if(!o.isSupported())return n.onError(`This browser cannot play HLS streams.`),{destroy:()=>void 0,levels:()=>[]};let s=new o({...a?{maxBufferLength:60,maxMaxBufferLength:120,backBufferLength:30,liveSyncDurationCount:4}:{backBufferLength:90},enableWorker:!0}),c=0,l=!1;s.on(o.Events.ERROR,(e,r)=>{if(!l&&r.fatal){if(c>=t){n.onError(`This stream kept failing and has been stopped.`),s.destroy();return}switch(c+=1,r.type){case o.ErrorTypes.NETWORK_ERROR:n.onNotice(`Reconnecting…`),s.startLoad();break;case o.ErrorTypes.MEDIA_ERROR:n.onNotice(`Recovering…`),s.recoverMediaError();break;default:n.onError(`This stream could not be played.`),s.destroy()}}}),s.on(o.Events.MANIFEST_PARSED,()=>{l||(n.onNotice(null),n.onReady?.({live:s.levels.length>0&&!Number.isFinite(r.duration),levels:u()}))}),s.on(o.Events.LEVEL_LOADED,(e,t)=>{l||n.onReady?.({live:t.details.live,levels:u()})}),s.on(o.Events.FRAG_BUFFERED,()=>{l||n.onNotice(null)});function u(){return s.levels.map((e,t)=>({index:t,height:e.height||null,bitrate:e.bitrate||null,label:e.height?`${String(e.height)}p`:`${String(Math.round((e.bitrate||0)/1e3))}k`}))}return s.loadSource(i),s.attachMedia(r),{destroy(){l=!0,s.destroy()},levels:u,setLevel(e){s.currentLevel=e},currentLevel:()=>s.autoLevelEnabled?-1:s.currentLevel}}export{n as createHlsEngine};