DisTube icon indicating copy to clipboard operation
DisTube copied to clipboard

PlayableExtractorPlugin error | Cannot read properties of undefined (reading 'playFromSource')

Open titsex opened this issue 7 months ago • 2 comments

I am writing my PlayableExtractorPlugin, and I came across the problem that when returning from the resolve method of the playlist, the error "PlayingError: Cannot read properties of undefined (reading 'playFromSource')".

Although if I return a specific Song, the music plays without problems.

Song:

export class VKMusicSong<T> extends Song<T> {
	constructor(plugin: VKMusicPlugin, info: IVKSong, options: ResolveOptions<T> = {}) {
		super(
			{
				plugin,
				source: VK_PLUGIN_SOURCE,
				playFromSource: true,
				id: info.id.toString(),
				url: info.url,
				name: info.title,
				duration: info.duration,
				isLive: false,
				uploader: {
					name: info.artist,
				},
			},
			options
		)
	}
}

I want to note that playFromSource is set to true here.

Playlist:

import { Playlist, type ResolveOptions } from 'distube'
import type { VKMusicSong } from './VKMusicSong'
import { VK_PLUGIN_SOURCE } from '@constant'
import type { IVKPlaylist } from '@types'

export class VKMusicPlaylist<T> extends Playlist<T> {
	constructor(info: IVKPlaylist, songs: VKMusicSong<T>[], options: ResolveOptions<T>) {
		super(
			{
				songs,
				source: VK_PLUGIN_SOURCE,
				id: info.id.toString(),
				name: info.title,
				thumbnail: info.photo.photo_1200,
			},
			options
		)
	}
}

The song list here is an array of instances of the VKMusicSong class, which was shown above.

And getStreamURL method: image

Also note: The getStreamURL method is not called when adding a playlist.

It works: image

It doesn't work: image

9WrCY8hBIc

titsex avatar Jul 14 '24 20:07 titsex