{"action":"created","issue":{"url":"https://api.github.com/repos/AlmasB/FXGL/issues/208","repository_url":"https://api.github.com/repos/AlmasB/FXGL","labels_url":"https://api.github.com/repos/AlmasB/FXGL/issues/208/labels{/name}","comments_url":"https://api.github.com/repos/AlmasB/FXGL/issues/208/comments","events_url":"https://api.github.com/repos/AlmasB/FXGL/issues/208/events","html_url":"https://github.com/AlmasB/FXGL/issues/208","id":168516699,"number":208,"title":"Music with a CycleCount > 1 removed from activeMusic, but not stopped","user":{"login":"Ergo21","id":6643026,"avatar_url":"https://avatars.githubusercontent.com/u/6643026?v=3","gravatar_id":"","url":"https://api.github.com/users/Ergo21","html_url":"https://github.com/Ergo21","followers_url":"https://api.github.com/users/Ergo21/followers","following_url":"https://api.github.com/users/Ergo21/following{/other_user}","gists_url":"https://api.github.com/users/Ergo21/gists{/gist_id}","starred_url":"https://api.github.com/users/Ergo21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ergo21/subscriptions","organizations_url":"https://api.github.com/users/Ergo21/orgs","repos_url":"https://api.github.com/users/Ergo21/repos","events_url":"https://api.github.com/users/Ergo21/events{/privacy}","received_events_url":"https://api.github.com/users/Ergo21/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-31T12:57:48Z","updated_at":"2016-07-31T13:04:43Z","closed_at":null,"body":"In FXGLAudioPlayer.kt:onUpdateEvent()\r\nThe following code has several issues,\r\n\r\nactiveMusic.filter { it.mediaPlayer.getCurrentTime() == it.mediaPlayer.getTotalDuration() }\r\n.forEach { it.isStopped = true }\r\n\r\n1. The test checks if the music has ended, but does not check if the music will cycle. Hence, if the music does cycle it is removed from the activeMusic, but continues to play.\r\n2. The result marks the music as stopped, but does not set it as stopped. Hence, an inconsistent state can occur i.e. Music marked as stopped, but not stopped.\r\n\r\nSuggested Fix\r\n\r\nactiveMusic.filter { (it.mediaPlayer.getCurrentTime() == it.mediaPlayer.getTotalDuration() && \r\n                             it.mediaPlayer.getCurrentCount() == it.mediaPlayer.getCycleCount()) }\r\n.forEach { \r\n      it.mediaPlayer.stop(); \r\n      it.isStopped = true; \r\n}"},"comment":{"url":"https://api.github.com/repos/AlmasB/FXGL/issues/comments/236428880","html_url":"https://github.com/AlmasB/FXGL/issues/208#issuecomment-236428880","issue_url":"https://api.github.com/repos/AlmasB/FXGL/issues/208","id":236428880,"user":{"login":"AlmasB","id":3594742,"avatar_url":"https://avatars.githubusercontent.com/u/3594742?v=3","gravatar_id":"","url":"https://api.github.com/users/AlmasB","html_url":"https://github.com/AlmasB","followers_url":"https://api.github.com/users/AlmasB/followers","following_url":"https://api.github.com/users/AlmasB/following{/other_user}","gists_url":"https://api.github.com/users/AlmasB/gists{/gist_id}","starred_url":"https://api.github.com/users/AlmasB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlmasB/subscriptions","organizations_url":"https://api.github.com/users/AlmasB/orgs","repos_url":"https://api.github.com/users/AlmasB/repos","events_url":"https://api.github.com/users/AlmasB/events{/privacy}","received_events_url":"https://api.github.com/users/AlmasB/received_events","type":"User","site_admin":false},"created_at":"2016-07-31T13:04:43Z","updated_at":"2016-07-31T13:04:43Z","body":"it.mediaPlayer.getCurrentTime() == it.mediaPlayer.getTotalDuration() takes into account all cycles, [javadoc](http://download.java.net/jdk8/jfxdocs/javafx/scene/media/MediaPlayer.html#getTotalDuration--) Do you have a minimal test example I can run?"}}
{"actor":{"display_login":"AlmasB"}}