diff --git a/play-dl/YouTube/stream.ts b/play-dl/YouTube/stream.ts index 4cb89d7..b9b7aef 100644 --- a/play-dl/YouTube/stream.ts +++ b/play-dl/YouTube/stream.ts @@ -19,7 +19,7 @@ export interface StreamOptions { language?: string; htmldata?: boolean; precache?: number; - optimization?: boolean + discordPlayerCompatibility?: boolean } /** @@ -87,8 +87,7 @@ export async function stream_from_info( final[0].codec === 'opus' && final[0].container === 'webm' ? StreamType.WebmOpus : StreamType.Arbitrary; await request_stream(`https://${new URL(final[0].url).host}/generate_204`); if (type === StreamType.WebmOpus) { - options.optimization ??= true - if(options.optimization){ + if(!options.discordPlayerCompatibility){ options.seek ??= 0 if (options.seek >= info.video_details.durationInSec || options.seek < 0) throw new Error(`Seeking beyond limit. [ 0 - ${info.video_details.durationInSec - 1}]`); @@ -100,7 +99,7 @@ export async function stream_from_info( info.video_details.url, options ); - } + } else if(options.seek) throw new Error("Can not seek with discordPlayerCompatibility set to true.") } return new Stream( final[0].url, diff --git a/play-dl/index.ts b/play-dl/index.ts index c2d2a20..60e1bc8 100644 --- a/play-dl/index.ts +++ b/play-dl/index.ts @@ -100,7 +100,7 @@ async function stream(url: string, options?: StreamOptions): Promise { @@ -240,7 +240,7 @@ async function stream_from_info(info: InfoData, options?: StreamOptions): Promis * - `number` quality : Quality number. [ 0 = Lowest, 1 = Medium, 2 = Highest ] * - `boolean` htmldata : given data is html data or not * - `number` precache : No of segments of data to store before looping [YouTube Live Stream only]. [ Defaults to 3 ] - * - `boolean` optimization : Conversion of Webm to Opus[ Defaults to true ] + * - `boolean` discordPlayerCompatibility : Conversion of Webm to Opus[ Defaults to true ] * @returns A {@link YouTubeStream} or {@link SoundCloudStream} Stream to play */ async function stream_from_info(