~autra/webapps-applications/deezer

« back to all changes in this revision

Viewing changes to src/Deezer/deezer.user.js

  • Committer: autra
  • Date: 2012-10-24 13:18:23 UTC
  • Revision ID: autra@autra-optiplex-380-20121024131823-q9lynuxmcsdewkng
adding launcher icon animation :
- number of track that will be played
- progress of current song

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
 
48
48
}
49
49
 
 
50
function refreshInfos () {
 
51
 
 
52
    //track info
 
53
    var trackInfo = getTrackInfo();
 
54
    Unity.MediaPlayer.setTrack(trackInfo);
 
55
 
 
56
    if (!trackInfo) {
 
57
        return;
 
58
    }
 
59
 
 
60
    // play pause button
 
61
    if (unsafeWindow.dzPlayer.isPlaying()) {
 
62
        Unity.MediaPlayer.setPlaybackState(Unity.MediaPlayer.PlaybackState.PLAYING);
 
63
    } else {
 
64
        Unity.MediaPlayer.setPlaybackState(Unity.MediaPlayer.PlaybackState.PAUSED);
 
65
    }
 
66
 
 
67
    //indicator : current track percent and number of tracks in the playlist
 
68
    Unity.Launcher.setCount(unsafeWindow.dzPlayer.getNbSongs() - unsafeWindow.dzPlayer.getNumSong());
 
69
    if (unsafeWindow.dzPlayer.isPlaying()) {
 
70
        Unity.Launcher.setProgress(unsafeWindow.dzPlayer.getPosition() /  unsafeWindow.dzPlayer.getDuration());
 
71
    }
 
72
    else {
 
73
        Unity.Launcher.clearProgress();
 
74
    }
 
75
}
 
76
 
50
77
function musicPlayerSetup() {
51
78
    console.log("start init deezer");
52
79
 
56
83
        if (!isCorrectPage()) {
57
84
            return;
58
85
        }
59
 
        var trackInfo = getTrackInfo();
60
 
        Unity.MediaPlayer.setTrack(trackInfo);
61
 
 
62
 
        if (!trackInfo) {
63
 
            return;
64
 
        }
65
 
 
66
 
        if (unsafeWindow.dzPlayer.isPlaying()) {
67
 
            Unity.MediaPlayer.setPlaybackState(Unity.MediaPlayer.PlaybackState.PLAYING);
68
 
        } else {
69
 
            Unity.MediaPlayer.setPlaybackState(Unity.MediaPlayer.PlaybackState.PAUSED);
70
 
        }
 
86
        refreshInfos();
 
87
 
71
88
    }), 1000);
72
89
 
73
90