public void playSong(Song song) throws NetworkException {
        ApiMusicImpl apiMusic = Controller.getInstance().getApiMusic();
        ApiProfileImpl apiProfile = ApiProfileImpl.getApiProfile();
        SongLibrary localSongLibrary = ApiProfileImpl.getApiProfile().getSongLibrary();
        SongLoader songLoader = new SongLoader();
        String path = null;
        boolean isLocal = false;
        
        // Get the path of the local song.
        if (localSongLibrary.islocal(song.getSongId())) {
            path = songLoader.getSongPath(song.getSongId());
            isLocal = true;
        } else if (isTmp(song)) {
            path = songLoader.generateTempSongPath(song.getOwnerId(), song.getSongId());
            isLocal = true;
        }
            
        // If the song is local play the temporary file else call the network.
        if (isLocal) {
            try {
                BitMusicPlayer.getInstance().play(path);
            } catch (JavaLayerException ex) {
                Logger.getLogger(SongPlayer.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(SongPlayer.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            apiMusic.getSongFile(apiProfile.getCurrentUser().getUserId(), song.getOwnerId(), song.getSongId(), true);
        }
    }