Skip to content

Commit f3d115e

Browse files
committed
fix: update playlist function syntax
1 parent ad78661 commit f3d115e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/PlayerScripts.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,16 @@ true;
4848

4949
loadPlaylist: (playList, startIndex, play) => {
5050
const index = startIndex || 0;
51-
const playlistJson = JSON.stringify(playList);
5251
const func = play ? 'loadPlaylist' : 'cuePlaylist';
5352

54-
return `player.${func}({playlist: ${playlistJson}, index: ${index}); true;`;
53+
const list = typeof playList === 'string' ? `"${playList}"` : 'undefined';
54+
const listType =
55+
typeof playList === 'string' ? `"${playlist}"` : 'undefined';
56+
const playlist = Array.isArray(playList)
57+
? `"${playList.join(',')}"`
58+
: 'undefined';
59+
60+
return `player.${func}({listType: ${listType}, list: ${list}, playlist: ${playlist}, index: ${index}}); true;`;
5561
},
5662

5763
loadVideoById: (videoId, play) => {

0 commit comments

Comments
 (0)