From f6287bc1b74fdbb2f813580e4c0bf9f115eb391d Mon Sep 17 00:00:00 2001 From: killer069 <65385476+killer069@users.noreply.github.com> Date: Tue, 14 Dec 2021 15:33:18 +0530 Subject: [PATCH] Added Docs for stream seek --- package-lock.json | 13 +++++++++++++ package.json | 9 ++++++--- play-dl/index.ts | 20 +++++++++++++++++++- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5bfed68..d25ed41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,9 @@ "name": "play-dl", "version": "1.5.0", "license": "GPL-3.0", + "dependencies": { + "play-audio": "^0.4.3" + }, "devDependencies": { "@types/node": "^16.9.4", "prettier": "^2.3.1", @@ -970,6 +973,11 @@ "node": ">= 6" } }, + "node_modules/play-audio": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/play-audio/-/play-audio-0.4.3.tgz", + "integrity": "sha512-DOLTP1+cgXH0k1ZdZyXXRsAPnVrzV2xZV6EXpWRsMtk24oolS7mD3WUQltuCeuJXKGM1tIsXLr+EZo6Ky4aKRg==" + }, "node_modules/postcss-load-config": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-3.1.0.tgz", @@ -2050,6 +2058,11 @@ "integrity": "sha512-ZIrVPH+A52Dw84R0L3/VS9Op04PuQ2SEoJL6bkshmiTic/HldyW9Tf7oH5mhJZBK7NmDx27vSMrYEXPXclpDKw==", "dev": true }, + "play-audio": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/play-audio/-/play-audio-0.4.3.tgz", + "integrity": "sha512-DOLTP1+cgXH0k1ZdZyXXRsAPnVrzV2xZV6EXpWRsMtk24oolS7mD3WUQltuCeuJXKGM1tIsXLr+EZo6Ky4aKRg==" + }, "postcss-load-config": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-3.1.0.tgz", diff --git a/package.json b/package.json index 055a265..4774fef 100644 --- a/package.json +++ b/package.json @@ -46,8 +46,11 @@ "prettier": "^2.3.1", "tsup": "^5.11.1", "typedoc": "^0.22.9", + "typedoc-plugin-extras": "^2.2.1", "typedoc-plugin-missing-exports": "^0.22.4", - "typescript": "^4.4.4", - "typedoc-plugin-extras": "^2.2.1" + "typescript": "^4.4.4" + }, + "dependencies": { + "play-audio": "^0.4.3" } -} \ No newline at end of file +} diff --git a/play-dl/index.ts b/play-dl/index.ts index cdadf95..6ab9d29 100644 --- a/play-dl/index.ts +++ b/play-dl/index.ts @@ -86,6 +86,8 @@ import { YouTubeChannel } from './YouTube/classes/Channel'; import { SpotifyAlbum, SpotifyPlaylist, SpotifyTrack } from './Spotify/classes'; import { DeezerAlbum, DeezerPlaylist, DeezerTrack } from './Deezer/classes'; +export async function stream(url: string, options: { seek? : number , seekMode?: 'precise' | 'granular'} & StreamOptions) : Promise +export async function stream(url: string, options? : StreamOptions) : Promise /** * Creates a Stream [ YouTube or SoundCloud ] class from a url for playing. * @@ -94,7 +96,14 @@ import { DeezerAlbum, DeezerPlaylist, DeezerTrack } from './Deezer/classes'; * const source = await play.stream('youtube video URL') // YouTube Video Stream * * const source = await play.stream('soundcloud track URL') // SoundCloud Track Stream - * + * + * const source = await play.stream('youtube video URL', { seek : 45 }) // Seeks 45 seconds (approx.) in YouTube Video Stream [ seekMode = "granular" ] + * // Granular = 1 - 9 seconds before given time. [ Fast ] + * // Precise = Exact seek [ Little bit Slow ] + * // Above command seeks to 45 seconds approximately while below command seeks to 45 seconds precisely + * + * const source = await play.stream('youtube video URL', { seek : 45, seekMode: "precise" }) // Seeks precisely to 45 seconds in YouTube Video Stream + * * const resource = createAudioResource(source.stream, { * inputType : source.type * }) // Use discordjs voice createAudioResource function. @@ -215,6 +224,8 @@ export async function search( else throw new Error('Not possible to reach Here LOL. Easter Egg of play-dl if someone get this.'); } +export async function stream_from_info(info: SoundCloudTrack, options? : StreamOptions) : Promise +export async function stream_from_info(info: InfoData, options? : StreamOptions) : Promise /** * Creates a Stream [ YouTube or SoundCloud ] class from video or track info for playing. * @@ -225,6 +236,13 @@ export async function search( * * const soundInfo = await play.soundcloud('SoundCloud URL') * const source = await play.stream_from_info(soundInfo) // SoundCloud Track Stream + * + * const source = await play.stream_from_info(info, { seek : 45 }) // Seeks 45 seconds (approx.) in YouTube Video Stream [ seekMode = "granular" ] + * // Granular = 1 - 9 seconds before given time. [ Fast ] + * // Precise = Exact seek [ Little bit Slow ] + * // Above command seeks to 45 seconds approximately while below command seeks to 45 seconds precisely + * + * const source = await play.stream_from_info(info, { seek : 45, seekMode: "precise" }) // Seeks precisely to 45 seconds in YouTube Video Stream * * const resource = createAudioResource(source.stream, { * inputType : source.type