メインコンテンツまでスキップ
バージョン: v2.0

クラス: YouTubeStreamProvider

定義: plugins/music-sources/src/youtube/YouTubeStreamProvider.ts:15

Track を実際の音声ストリームへ変換するコンポーネント。 providers/ ディレクトリに置くと自動ロードされます。

Resolver(何を再生するか)と Provider(どこから音を取るか)を分けている ため、片方が壊れてももう片方は生き残ります。例えば YouTube の抽出が 壊れたときは Provider を差し替えるだけで、Spotify の解決処理はそのまま 使えます。

@StreamProvider.define({ priority: 10 })
export class MyProvider extends StreamProvider {
canStream(track: Track) { return track.source === "my-resolver"; }
async stream(track: Track): Promise<AudioStream> {
return { stream: await openStream(track.url), type: StreamType.WebmOpus };
}
}

拡張

コンストラクター

コンストラクター

new YouTubeStreamProvider(): YouTubeStreamProvider;

戻り値

YouTubeStreamProvider

継承元

StreamProvider.constructor

プロパティ

container

readonly container: Container;

定義: src/component/Component.ts:30

フレームワーク共有サービスを持つコンテナ。

継承元

StreamProvider.container


location

readonly location: string | null;

定義: src/component/Component.ts:39

自動探索されたファイルの絶対パス。明示登録の場合は null

継承元

StreamProvider.location


logger

readonly logger: Logger;

定義: src/component/Component.ts:36

このコンポーネント用の子ロガー({ store, component } が付与済み)。

継承元

StreamProvider.logger


name

readonly name: string;

定義: src/component/Component.ts:27

ストア内で一意なコンポーネント名。

継承元

StreamProvider.name


priority

readonly priority: number;

定義: plugins/music/src/StreamProvider.ts:57

継承元

StreamProvider.priority


store

readonly store: ComponentStore<Component>;

定義: src/component/Component.ts:33

このコンポーネントが属するストア。

継承元

StreamProvider.store

アクセッサー

client

署名を取得する

get client(): Client;

定義: src/component/Component.ts:42

フレームワーククライアント。

戻り値

Client

継承元

StreamProvider.client


services

署名を取得する

get services(): Services;

定義: src/component/Component.ts:50

ロード済みサービスへのアクセス(services/ から自動収束)。 import せずに this.services.<名前> で参照できます。

戻り値

Services

継承元

StreamProvider.services

メソッド

canStream()

canStream(track): boolean;

定義: plugins/music-sources/src/youtube/YouTubeStreamProvider.ts:21

このトラックを再生できるか。副作用のない高速な判定にしてください。

パラメータ

track

Track

戻り値

boolean

上書き

StreamProvider.canStream


onLoad()

onLoad(): void;

定義: plugins/music-sources/src/youtube/YouTubeStreamProvider.ts:17

デコレータの値は静的なので、設定された優先度をここで反映する。

戻り値

void

上書き

StreamProvider.onLoad


onUnload()?

optional onUnload(): unknown;

定義: src/component/Component.ts:58

ストアから取り除かれるときに呼ばれます(クライアント終了時を含む)。

戻り値

unknown

継承元

StreamProvider.onUnload


stream()

stream(track): Promise<AudioStream>;

定義: plugins/music-sources/src/youtube/YouTubeStreamProvider.ts:25

トラックの音声ストリームを開きます。

パラメータ

track

Track

戻り値

Promise<AudioStream>

上書き

StreamProvider.stream


define()

static define(options?): (_target, context) => void;

定義: plugins/music/src/StreamProvider.ts:59

パラメータ

options?

StreamProviderOptions = {}

戻り値

(_target, context) => void

継承元

StreamProvider.define