-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closes issue #222. Autoplay of suggested next video. Button toggle. Does not play duplicates by maintaining history of all videos. #231
Conversation
Closes zen-audio-player#193 Add support for linking to a specific time position
…video. History also maintained of all videos played to avoid duplicates
var playList = []; | ||
var autoplayState; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: too many blank lines
Thanks for the efforts here @cipher1729!
If these tests are failing, functionality is broken.
{
"items": [
{
"type": "youtube",
"id": "12345678911",
"played": false
}
],
"autoplaying": false
} I'm always open to suggestions 💭 |
Thanks for the feedback @shakeelmohamed . I'll try to fix issues asap |
@@ -580,32 +573,32 @@ $(function() { | |||
// How do we know if the value is truly invalid? | |||
// Preload the form from the URL | |||
var currentVideoID = getCurrentVideoID(); | |||
if (currentVideoID) { | |||
if (currentVideoID) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put the brace at the end of the previous line (with a space after the )
)
…" : "true"/"false" , items=[ {"type":"youtube", "id":videoId, "played":true}, ... ] }
$("#toggleAutoplay").click(function(event) | ||
{ | ||
var toggleTextElement = $("#" + event.currentTarget.id); | ||
if (autoplayState === null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code can be simplified by using an if condition of !!autoplayState
which converts the value to a boolean, null
will evaluate to false
.
ie:
> var vals = [null, false, true];
undefined
> for (var v in vals) { console.log(!!vals[v]); }
false
false
true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like your logic but eslint complains: "Redundant double negation"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, just use autoplayState
as the condition. The same boolean rules will apply inside an if/loop condition
I've made some additional eslint changes, please merge in the latest master branch. This will catch many of the style-related things I would've commented on |
I think i've incorporated all changes |
toggleTextElement.text("Stop autoplay"); | ||
} | ||
else { | ||
if (autoplayState === "true") | ||
{ | ||
if (autoplayState === true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need to compare a truthy value to true
, it can just be if (autoplayState) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cipher1729 ping 😃
Hey @shakeelmohamed , sorry been crazy busy, will get back to this asap |
Cleaned up the code from pull request zen-audio-player#231. Then fixed some bugs: (1) Fixed getNewVideoID function. Previously it just popped up all the playList and left only the first element. And if this element would be current video id then nextId will be set to null. Now I've made a reverse for playlist array to get just the same next video from YouTube as Youtube suggests itself and that is done with no further changes in the code. I've also removed the while loop from getNewVideoID function and that gives the code an opportunity to check all the playlist for a next track during the session. (2) Fixed the problem when tracks were added to videoMetadata["items"] when they were already there. Now there is a clause that checks if current track has already been played and if so just doesn't add a duplicate.
Closing due to inactivity |
Provide a general summary of your changes in the Title above.
Important
Mark with [x] to select. Leave as [ ] to unselect.
Motivation and Context
Closes #1
(where 1 would be the issue number) to your commit message.Closes Autoplay Feature from Youtube #222
Types of changes
What types of changes does your code introduce? Check all the boxes that apply:
Description
Added an autoplay button with two states - 'start autoplay' and 'stop autoplay'. With autoplay ON, similar videos keep playing one after the other. 'stop autoplay' disables this feature. History of videos played till now is stored and accessed from local session storage.
Final checklist:
Go over all the following points and check all the boxes that apply
If you're unsure about any of these, don't hesitate to ask. We're here to help!
Last two tests "Demo" and "Form" fail - they complain about actions performed on null DOM objects. Maybe it has something to do with the order the player components and the page itself are loaded. The Demo still works, if the button is clicked manually.