Search in sources :

Example 11 with MPDTrack

use of org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDTrack in project malp by gateship-one.

the class MPDInterface method getCurrentSong.

/**
 * This will query the current song playing on the mpd server.
 *
 * @return MPDTrack entry for the song playing.
 */
public synchronized MPDTrack getCurrentSong() throws MPDException {
    mConnection.sendMPDCommand(MPDCommands.MPD_COMMAND_GET_CURRENT_SONG);
    // Reuse the parsing function for tracks here.
    List<MPDFileEntry> retList;
    retList = MPDResponseParser.parseMPDTracks(mConnection);
    if (retList.size() == 1) {
        MPDFileEntry tmpFileEntry = retList.get(0);
        if (null != tmpFileEntry && tmpFileEntry instanceof MPDTrack) {
            return (MPDTrack) tmpFileEntry;
        }
        return null;
    } else {
        return null;
    }
}
Also used : MPDFileEntry(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDFileEntry) MPDTrack(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDTrack)

Example 12 with MPDTrack

use of org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDTrack in project malp by gateship-one.

the class MainActivity method onContextItemSelected.

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    if (info == null) {
        return super.onContextItemSelected(item);
    }
    CurrentPlaylistView currentPlaylistView = findViewById(R.id.now_playing_playlist);
    if (currentPlaylistView != null && mNowPlayingDragStatus == DRAG_STATUS.DRAGGED_UP) {
        MPDTrack track = (MPDTrack) currentPlaylistView.getItem(info.position);
        switch(item.getItemId()) {
            case R.id.action_song_play_next:
                MPDQueryHandler.playIndexAsNext(info.position);
                return true;
            case R.id.action_add_to_saved_playlist:
                // open dialog in order to save the current playlist as a playlist in the mediastore
                ChoosePlaylistDialog choosePlaylistDialog = new ChoosePlaylistDialog();
                Bundle args = new Bundle();
                args.putBoolean(ChoosePlaylistDialog.EXTRA_SHOW_NEW_ENTRY, true);
                choosePlaylistDialog.setCallback(new AddPathToPlaylist(track, this));
                choosePlaylistDialog.setArguments(args);
                choosePlaylistDialog.show(getSupportFragmentManager(), "ChoosePlaylistDialog");
                return true;
            case R.id.action_remove_song:
                MPDQueryHandler.removeSongFromCurrentPlaylist(info.position);
                return true;
            case R.id.action_remove_album:
                currentPlaylistView.removeAlbumFrom(info.position);
                return true;
            case R.id.action_show_artist:
                if (mUseArtistSort) {
                    onArtistSelected(new MPDArtist(track.getTrackArtistSort()), null);
                } else {
                    onArtistSelected(new MPDArtist(track.getTrackArtist()), null);
                }
                return true;
            case R.id.action_show_album:
                MPDAlbum tmpAlbum = new MPDAlbum(track.getTrackAlbum());
                // Set album artist
                if (!track.getTrackAlbumArtist().isEmpty()) {
                    tmpAlbum.setArtistName(track.getTrackAlbumArtist());
                } else {
                    tmpAlbum.setArtistName(track.getTrackArtist());
                }
                // Set albumartistsort
                if (!track.getTrackAlbumArtistSort().isEmpty()) {
                    tmpAlbum.setArtistSortName(track.getTrackAlbumArtistSort());
                } else {
                    tmpAlbum.setArtistSortName(track.getTrackArtistSort());
                }
                tmpAlbum.setMBID(track.getTrackAlbumMBID());
                onAlbumSelected(tmpAlbum, null);
                return true;
            case R.id.action_show_details:
                // Open song details dialog
                SongDetailsDialog songDetailsDialog = new SongDetailsDialog();
                Bundle songArgs = new Bundle();
                songArgs.putParcelable(SongDetailsDialog.EXTRA_FILE, track);
                songDetailsDialog.setArguments(songArgs);
                songDetailsDialog.show(getSupportFragmentManager(), "SongDetails");
                return true;
        }
    }
    return false;
}
Also used : AddPathToPlaylist(org.gateshipone.malp.application.callbacks.AddPathToPlaylist) MPDTrack(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDTrack) MPDAlbum(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDAlbum) Bundle(android.os.Bundle) ChoosePlaylistDialog(org.gateshipone.malp.application.fragments.serverfragments.ChoosePlaylistDialog) AdapterView(android.widget.AdapterView) MPDArtist(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDArtist) CurrentPlaylistView(org.gateshipone.malp.application.views.CurrentPlaylistView) SongDetailsDialog(org.gateshipone.malp.application.fragments.serverfragments.SongDetailsDialog)

Example 13 with MPDTrack

use of org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDTrack in project malp by gateship-one.

the class FilesFragment method onCreateContextMenu.

/**
 * Create the context menu.
 */
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getActivity().getMenuInflater();
    int position = ((AdapterView.AdapterContextMenuInfo) menuInfo).position;
    MPDFileEntry file = (MPDFileEntry) mAdapter.getItem(position);
    if (file instanceof MPDTrack) {
        inflater.inflate(R.menu.context_menu_track, menu);
    } else if (file instanceof MPDDirectory) {
        inflater.inflate(R.menu.context_menu_directory, menu);
    } else if (file instanceof MPDPlaylist) {
        inflater.inflate(R.menu.context_menu_playlist, menu);
    }
}
Also used : MPDFileEntry(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDFileEntry) MPDTrack(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDTrack) MenuInflater(android.view.MenuInflater) MPDDirectory(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDDirectory) MPDPlaylist(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDPlaylist)

Example 14 with MPDTrack

use of org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDTrack in project malp by gateship-one.

the class PlaylistTracksFragment method playNext.

private void playNext(int index) {
    MPDTrack track = (MPDTrack) mFileAdapter.getItem(index);
    MPDQueryHandler.playSongNext(track.getPath());
}
Also used : MPDTrack(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDTrack)

Example 15 with MPDTrack

use of org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDTrack in project malp by gateship-one.

the class PlaylistTracksFragment method play.

private void play(int index) {
    MPDTrack track = (MPDTrack) mFileAdapter.getItem(index);
    MPDQueryHandler.playSong(track.getPath());
}
Also used : MPDTrack(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDTrack)

Aggregations

MPDTrack (org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDTrack)25 MPDFileEntry (org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDFileEntry)7 Bundle (android.os.Bundle)4 MPDAlbum (org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDAlbum)4 MPDDirectory (org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDDirectory)4 MPDPlaylist (org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDPlaylist)4 AppCompatActivity (android.support.v7.app.AppCompatActivity)3 AdapterView (android.widget.AdapterView)3 AddPathToPlaylist (org.gateshipone.malp.application.callbacks.AddPathToPlaylist)3 MPDCurrentStatus (org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDCurrentStatus)3 FileListItem (org.gateshipone.malp.application.listviewitems.FileListItem)2 MPDArtist (org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDArtist)2 Bitmap (android.graphics.Bitmap)1 MenuInflater (android.view.MenuInflater)1 VolleyError (com.android.volley.VolleyError)1 ArrayList (java.util.ArrayList)1 ImageNotFoundException (org.gateshipone.malp.application.artworkdatabase.ImageNotFoundException)1 FanartFetchError (org.gateshipone.malp.application.artworkdatabase.network.responses.FanartFetchError)1 TrackAlbumFetchError (org.gateshipone.malp.application.artworkdatabase.network.responses.TrackAlbumFetchError)1 ChoosePlaylistDialog (org.gateshipone.malp.application.fragments.serverfragments.ChoosePlaylistDialog)1