Есть ли способ поменять канал кнопкой с API YouTube? - PullRequest
0 голосов
/ 28 марта 2019

Я хочу «перейти» с последнего видео, загруженного с канала на другой, когда я нажимаю на кнопку.

Теперь я могу перейти к предыдущему или следующему видео другим способом. Но я не знаю, как я могу перейти с одного канала на другой ...

Вот мой код:

// CHANNEL'S LIST
var channels = [
    marvel.channelName,
    dcComics.channelName,
    miniac.channelName,
    tabletopMinions.channelName,
    nextLevelPainting.channelName,
    angelGiraldez.channelName,
    theBeastsOfWar.channelName,
    corvusBelli.channelName
];

var player;
function onYouTubeIframeAPIReady() {
    player = new YT.Player('player', {
        height: '315',
        width: '560',
        autoplay: '0',
        controls: '1',
        rel: '0',
        fs: '0',
        modestbranding: '1',

        events: {
            'onReady': onPlayerReady
        }
    });
}

function onPlayerReady(event) {
    event.target.loadPlaylist({
        list: channels,
        listType: 'user_uploads'
    });
}

// CHANNEL NAVIGATION FUNCTION

var currentChannel = 0;

// Next
function nextChannel() {
    currentChannel++;

    if (currentChannel > channels.length) {
        currentChannel = channels.length;
    }
}

// Previous
function prevChannel() {
    currentChannel--;

    if (currentChannel < 0) {
        currentChannel = 0;
    }
}

// Playback Controls
$("#next").click( function () {
    player.nextVideo();
});
$("#prev").click( function () {
    player.previousVideo();
});
...