Skip to content

Commit

Permalink
fix: update playlist function syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
LonelyCpp committed Nov 19, 2021
1 parent ad78661 commit f3d115e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/PlayerScripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,16 @@ true;

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

return `player.${func}({playlist: ${playlistJson}, index: ${index}); true;`;
const list = typeof playList === 'string' ? `"${playList}"` : 'undefined';
const listType =
typeof playList === 'string' ? `"${playlist}"` : 'undefined';
const playlist = Array.isArray(playList)
? `"${playList.join(',')}"`
: 'undefined';

return `player.${func}({listType: ${listType}, list: ${list}, playlist: ${playlist}, index: ${index}}); true;`;
},

loadVideoById: (videoId, play) => {
Expand Down

0 comments on commit f3d115e

Please sign in to comment.