All instructions for Step 2 - Step 7 can be found in Post #3 and Post #5?
I think there are only instructions on how to do Step 1, which can be found in Post #5.
I see: Step 1
Step 1: Change needed private functions to be public
I don’t see Step 2
Am I supposed to be waiting for those before going ahead?
Should I be waiting for further instruction, guidance?
Sometimes I think I can go ahead on my own, thinking I know what to do, then I end up getting it all messed up and wrong because I am doing too many things at once.
I asked because I am stuck here.
There is an issue I run into when moving 2 functions into onYouTubeIframeAPIReady.
The code stops working: https://jsfiddle.net/7toykpu2/1/
I am stuck and confused.
These are the 2 functions being moved.
Is that wrong?
function createCoverClickHandler(playerOptions) {
function addPlayer(coverSelector, playerOptions) {
After moving those 2 functions out, should the code still be working right away?
or, am I supposed to be making other changes also?
The return I think should only have show in it I think.
This
return {
show
};
Not this:
return {
add: addPlayer,
createCoverClickHandler,
createPlayer,
show
};
I tried:
add: show
Did not work.
show: show
Did not work.
addPlayer: show
Did not work.
What am I doing wrong?
I don’t know how to move the functions out without the code falling apart.
I can’t do anything without making other changes, and I don’t know what to do next.
function show(el) {
el.classList.remove("hide");
}
function combinePlayerOptions(opts1 = {}, opts2 = {}) {
const combined = Object.assign({}, opts1, opts2);
Object.keys(opts1).forEach(function checkObjects(prop) {
if (typeof opts1[prop] === "object") {
combined[prop] = Object.assign({}, opts1[prop], opts2[prop]);
}
});
return combined;
}
function createPlayer(videoWrapper, playerOptions = {}) {
const video = videoWrapper.querySelector(".video");
const options = combinePlayerOptions(defaults, playerOptions);
return videoPlayer.addPlayer(video, options);
}
return {
add: addPlayer,
createCoverClickHandler,
createPlayer,
show
};
}());
function onYouTubeIframeAPIReady() {
function createCoverClickHandler(playerOptions) {
return function coverClickHandler(evt) {
const cover = evt.currentTarget;
const wrapper = cover.nextElementSibling;
show(wrapper);
const player = createPlayer(wrapper, playerOptions);
wrapper.player = player;
};
}
function addPlayer(coverSelector, playerOptions) {
const clickHandler = createCoverClickHandler(playerOptions);
manageCover.addCoverHandler(coverSelector, clickHandler);
}
managePlayer.show(".playa", {});
managePlayer.show(".playb", {});
managePlayer.show(".playc", {});
managePlayer.show(".playd", {});
managePlayer.show(".playe", {
playerVars: {
playlist: "0dgNc5S8cLI,mnfmQe8Mv1g,-Xgi_way56U,CHahce95B1g"
}
});
managePlayer.show(".playe", {});
managePlayer.show(".playf", {});
managePlayer.show(".playg", {});
managePlayer.show(".playh", {});