Commit graph

329 commits

Author SHA1 Message Date
Hyzual
b51e033c25 Merge branch 'rewrite_player' into develop 2015-01-17 19:42:30 +01:00
Hyzual
40c4b5cba2 4.4.0 Rewrites player
It's mostly a tech version, on the user-side a few bugs should be fixed but there are no new features
- Fixes the bug with ping() in the settings
- Adds a generic subsonicRequest() that handles protocols and errors. It makes getRandomSongs, getStarredSongs, scrobble, etc. very light : they only deal with getting songs (or scrobbling).
- Adds a separate controller for the queue
- Adds a separate controller for the player controls
- Adds a separate directive that controls jplayer
- New rewritten player service
- Adds a persistence service, used to store the playing queue and current song in localStorage
- Mostly rewritten notifications service, displays the current playing song, takes a song as parameter
- Adds a Page service, controls the tab title in order to display (or scroll) a song's title
- Removed many things from main-controller, utils, settings, etc. They are all moved somewhere else where it makes more sense
- Updated bower dependencies: jplayer, jquery and jquery-ui
2015-01-17 19:42:09 +01:00
Hyzual
2a4f89b182 Fixes the loop queue code
It had probably stopped working after I fixed the index detection code to allow for dragging and dropping songs.
2015-01-17 19:15:11 +01:00
Hyzual
e6cf49c6d3 Fixes an error on load: player directive would try to play a song even if none was loaded. 2015-01-17 19:15:10 +01:00
Hyzual
7f84cf7b98 Fixes tsquillario/Jamstash#192
Adds a ping() function to the subsonic service, taking advantage of our new subsonicRequest wrapper. It works with both JSON and JSONP, catches errors, etc.
Errors from an incorrect parameter (missing password) or unreachable server should now be displayed to the user.
2015-01-17 19:15:10 +01:00
Hyzual
520d3672f7 Changes the player controller
- It no longer exposes the entire player service to the scope. It provides 5 functions : play; pause, previous, next and getPlayingSong
play and pause are only meant for the jukebox mode, normally it is jPlayer that manages the buttons directly.
- Playing a song in jukebox mode mutes jPlayer
- Adds tests for those modifications
2015-01-17 19:15:10 +01:00
Hyzual
5759003f12 Adds working but unstable jukebox controls
The play/pause button is managed manually and can send commands to the jukebox.
But it also sends play/pause commandes to jPlayer, which causes js errors.
Additionally, we have no idea of the current position of the song.
2015-01-17 19:15:10 +01:00
Hyzual
8b3a12f052 Moves drag & drop support from main-controller.js to queue.js
Adds a indexOfSong method to player-service. It is used in play, nextTrack and previousTrack so the player can adapt to changes to the queue order. Previously it wasn't taken into account and when we changed the order of the queue (through drag & drop or shuffle), the next song wasn't what we expected it to be.
2015-01-17 19:15:10 +01:00
Hyzual
09fb66f2fe Adds back support of oga and m4a
- Fixes the various remaining calls to $rootScope.queue. They now use the player service.
- main-controller.js watches the player's queue and shows the queue on change (if the global setting is true)
- Fixes the animation of the scrubber width. It is now done in the player directive.
2015-01-17 19:15:09 +01:00
Hyzual
95c791fa40 Fixes a bug where after loading a song from localStorage, it would be played twice.
- This was due to the way we searched for the song's index in the queue.
2015-01-17 19:15:09 +01:00
Hyzual
3324113af8 When changing song, if fancybox is open, opens the new song's cover art in it
- Fixes a bug with the Page service. There was an error when changing songs.
- Removes fancyboxOpenImage from utils, it's directly in the main controller so we can call it from the directive. It didn't need to be in a service anymore since we have a player directive.
2015-01-17 19:15:09 +01:00
Hyzual
c478f0116f Replaced utils setTitle and scrollTitle by a dedicated service
- Adds a Page service that will control the page's title from anywhere.
- Adds a setTitleSong method. It takes a song as parameter, that way
  player-directive isn't responsible for correctly formatting the title. It also scrolls the title if the global setting is true
- Removes the title-related methods from utils-service
2015-01-17 19:15:09 +01:00
Hyzual
0646b02e94 When playing, adding or displaying a random playlist, it is correctly shown as selected 2015-01-17 19:15:08 +01:00
Hyzual
425bac6676 When playing a song, the queue is scrolled to display it 2015-01-17 19:15:08 +01:00
Hyzual
392ef74eba Rewrites notification service
- showNotification takes a song as parameter and picks the information it needs itself. That way we avoid player-directive.js having utils as a dependency.
- shortened the names of the methods a bit. Had to rename them in settings.js
- Used $interval rather than window.setInterval in player-directive.js and in notification-service.js. It's easier to unit test them that way !
2015-01-17 19:15:08 +01:00
Hyzual
33f1a88d6b Adds the generic requestSongs function to subsonic.js.
It handles displaying, adding or playing songs, whatever their source. It also handles error notifications for subsonic, http or service errors.

- Changes all calls to getRandomSongs in the template so they provide the 'display' parameter and do not provide any param when they aren't needed.
- Adds genre and folder parameters to getRandomSongs
- getRandomStarredSongs now maps the songs (using model) before returning them
2015-01-17 19:15:08 +01:00
Hyzual
4d4710ddb6 Settings use persistence instead of player for localStorage-related operations. 2015-01-17 19:15:08 +01:00
Hyzual
dc280594ab Refactor subsonic getRandomSongs() so that it returns a promise
I have now to fix the functions that called it from the scope (random autoplaylist and others)
This fixes the problem with AutoPlay not updating : since $q's promises are integrated with scope, we now see immediately the new songs being added.
2015-01-17 19:15:07 +01:00
Hyzual
446e653048 Refactor getStarred, getRandomStarred and scrobble in subsonic-service.js
They now use the new subsonicRequest() method which frees us from having to rebuild the complete URL with all the params. It handles JSONP/JSON and it also does most of the error-handling, so we can focus on displaying more specific messages in every request.

- Renamed playingIndex and playingSong in player-service.js to "private variables" starting with '_'. They only are public for testing purposes and are not meant to be manipulated directly.
2015-01-17 19:15:07 +01:00
Hyzual
2e004a5f59 Adds deleting the queue and song from localStorage.
Adds a watch on the saveTrackPosition setting to start dynamically saving the position.
2015-01-17 19:15:07 +01:00
Hyzual
42830bbdbf Extracts everything related to localStorage in common/persistence-service.js
That way, whenever we want to use something else (like a JSON file, or a DB) we will only have to change persistence-service.js
- Migrated the unit tests there too.
- Added replay in case of jPlayer error.
2015-01-17 19:15:07 +01:00
Hyzual
3c809d1903 Adds back displaying the currently playing song as such in the queue
We no longer alter the song, the queue gets this from the player.
That way we can't have two songs marked as 'playing' at the same time.
2015-01-17 19:15:07 +01:00
Hyzual
c787c468b9 Further refactoring of the queue controller and view
- Removes queue-related functions from the main controller. They are now handled by queue.js, which delegates them to player-service.js
- Fixes problem in scrobbling. A song is no longer scrobbled every time it is paused. A song will not be scrobbled upon loading, only while it is playing.
- Moves the entire html for the sidebar queue to queue.html. It replaces a template that was no longer used.
- Most queue-related functions in player return player itself to make them chainable just like in jQuery, e.g. : player.shuffleQueue().playFirstSong();
2015-01-17 19:14:25 +01:00
Hyzual
83869b7808 Adds angular-locker dependency.
- It makes it easier to use localStorage and sessionStorage "the angular way". It also does all the error handling so we don't need to.
- Adds back the automatic saving of the current track's position and playing queue in localStorage. It's fully unit tested.
- Adds back the notifications. Every time we change songs (if the setting is true), it displays a notification. Clicking on it goes to the next song, just like before.
- Bumps up the versions to the actual value on the various json files.
2015-01-17 19:13:43 +01:00
Hyzual
2e97e25f25 Adds back AutoPlay, Loop Queue and Repeat support.
- AutoPlay still has a problem with scope apply. Since it's asynchronous, the directive needs to know when it's finisehd to use scope apply... That means more subsonic refactoring.
- Adds unit tests for Repeat song and Loop Queue
- Adds back a special function in the player Service to manage the end of a song.
2015-01-17 19:13:42 +01:00
Hyzual
834e67946c Adds back scrobbling and loading a track and the queue from localStorage.
- Splits loadTrackPosition into two functions : one for the track (which isn't finished), one for the queue.
- Adds main-controller.js' first unit tests for both these functions.
- Adds scrobbling functionnality. It is now a part of the Subsonic service, since we it's Subsonic that ultimately does the scroblling.
- Adds unit tests for both the service and the directive. The test for updatetime was crazy hard to do because I had to find a way to trigger my own fake event and it wasn't permitted by jplayer.
- Adds the load function to the player, it is used only when loading a song from localStorage.
- Removes ng-click from play/pause in the player template. jPlayer adds its own handlers on them, no need to do it twice.
2015-01-17 19:13:42 +01:00
Hyzual
59762ae423 Adds unit tests on the jplayer directive.
The major functionnalities are tested :
- play the next song when the current song ends
- change the current song with the player service
- restart the current song with the player service
- Show the player controls and song details when playing a song

Adds jasmine-fixtures dev dependency (needed for the visibility test)
2015-01-17 19:13:42 +01:00
Hyzual
7074e9abc8 Adds more methods to control the queue in the player service.
- Adds : empty queue, shuffle queue, add one song to queue, remove one song from queue, restart the current song
- Removes the "playEnded" method : we now use correctly scope.$apply() in the directive after calling nextTrack(). The next song is correctly called after the end of the current one.
- Starts replacing the old rootScope functions with calls to the player service.
2015-01-17 19:13:42 +01:00
Hyzual
f4afa67598 Updates bower dependencies : jplayer, jquery, jquery-ui. 2015-01-17 19:13:42 +01:00
Hyzual
19661f463b Fixes the communication between the player directive and the player service
- Adds a "playEnded()" function specifically for jplayer to call when the currently playing song ends. It uses $rootScope.$apply() to notify the directive that the song has changed.
- Shows the player controls' css.
- Marks the tests relating the "playing" status of the song as pending.
- Further uses the Player service in the subsonic view
2015-01-17 19:13:41 +01:00
Hyzual
f6d2286456 Adds the player Service directly to the scope in the player controller.
Adds a "playFirstSong" function to the service, which will be used in Subsonic controller.
2015-01-17 19:13:41 +01:00
Hyzual
88b1e6a6e6 Rewrites the entire player component.
Not finished ! This is still work in progress and fairly broken in this commit.
The jquery jplayer is now wrapped in an angular directive.
The queue is no longer being managed in rootScope but is a part of the player service. It can be accessed like before and emptied / filled.
The player controller also uses the player service now.
2015-01-17 19:13:40 +01:00
Hyzual
e51961c167 Starts rewriting the player service.
The API is simplified: we can play a song, restart the currently playing song, load a song (that'll be used only by local storage), play the next track or the previous track.

As a result, I changed all the calls to playSong(false, song) which are now just play(song)
2015-01-17 19:13:40 +01:00
Hyzual
226a768987 Renamed all controlles from 'Ctrl' to 'Controller' to better follow angular best practices. 2015-01-17 19:13:40 +01:00
Hyzual
91b112cb0a Fixes the queue test 2015-01-17 19:12:56 +01:00
Hyzual
e5846e30f9 Removes the player functions from the rootScope.
However, saving track's position is broken.
Some are still there because of problems I don't know how to solve, e.g. circular dependency between notifications and player.
Uses the queue controller for the sidebar queue.
Moves loadTrackPosition to the main controller.
2015-01-17 19:12:56 +01:00
Hyzual
74ac275ece Refactors the player service.
The idea is that the service should ideally be used directly, so we know who depends on what and don't end up with cycles.
To achieve this, we should not add functions to $rootScope but instead provide them from our service.
Services can use them directly, and controllers have to create other functions in their own scope.

This means that we have a player-controller that does not do much by itself but it enables us to avoid filling up the $rootScope.

I have left the $rootScope additions at the end of player-service because it's going to take some time to refactor it, so in the meantime I want things to keep working.
2015-01-17 19:12:56 +01:00
Hyzual
1a01c4c23c First green test : changing nextTrack so it is not in the rootScope. 2015-01-17 19:12:56 +01:00
Hyzual
8fff3c8597 Adds size attributes to all images in player.
Renames images to correspond to their actual size
2015-01-17 19:12:55 +01:00
Hyzual
608d4f98e2 Extracts the player into its own files.
Creates a player directive, controller and service.
Moves the HTML from inside index.html to its own player.html file.

Conflicts:
	app/index.html
2015-01-17 19:12:55 +01:00
Hyzual
a0a697d3e2 Merge branch 'grunt' into develop 2015-01-17 19:03:57 +01:00
Hyzual
bf5f01d825 Replaces karma-growl-reporter by karma-notify-reporter
notify can use the native Windows 8, OS X and Linux notifications, and also supports Growl as a fallback.
2015-01-17 19:03:24 +01:00
Hyzual
e73d23bbaa Fixes the build with jit-grunt
Adds aliases to plugin that have different task names relative to the plugin name
2015-01-17 19:03:00 +01:00
Hyzual
96cc13b8a9 Replaces (load-grunt-task' by 'jit-grunt'. Only the needed tasks are loaded, so that watch is not slowed down by imagemin. 2015-01-17 19:02:48 +01:00
Hyzual
a8053384e9 Shorten grunt builds by moving 'load-grunt-tasks' inside each grunt registered task.
That way we avoid loading imagemin everytime on watch, which was the longest (almost 30sec).
We only have to load 'grunt-karma' everytime, but now testing is lightning fast !
2015-01-17 19:02:47 +01:00
Hyzual
4e8979c8e0 Adds grunt-notify. Adds 'coverage' task to open the coverage dir in the browser. 2015-01-17 19:02:47 +01:00
Hyzual
ce53362fbb Adds the Growl reporter for karma.
Removes the sellout package, it can always be installed globally and is not needed.
2015-01-17 19:02:47 +01:00
Hyzual
f1bda7eea8 Adds an editor config file
It is used to keep contributors' editors config in sync, so we all use 4 spaces indent.
2015-01-17 19:02:05 +01:00
Hyzual
b2a426eaa2 Adds karma-coverage to generate test coverage reports using Istanbul.
Test coverage files are in the /coverage folder.
They indicate us for each js file which lines we ran and which we didn't run during unit tests. This helps us know what to test next.

Conflicts:
	package.json
2015-01-17 18:59:44 +01:00
Trevor Squillario
1b526970b3 4.3.3 ApiVersion workaround, stopped working with jsonp 2015-01-05 19:24:59 -05:00