Search in sources :

Example 1 with SongHelper

use of com.jams.music.player.Helpers.SongHelper in project JamsMusicPlayer by psaravan.

the class QueueDrawerAdapter method getView.

public View getView(final int position, View convertView, ViewGroup parent) {
    QueueDrawerHolder holder;
    if (convertView == null) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.queue_drawer_list_layout, parent, false);
        holder = new QueueDrawerHolder();
        holder.songTitleText = (TextView) convertView.findViewById(R.id.queue_song_title);
        holder.artistText = (TextView) convertView.findViewById(R.id.queue_song_artist);
        holder.removeSong = (ImageView) convertView.findViewById(R.id.queue_remove_song);
        holder.songTitleText.setTextColor(UIElementsHelper.getThemeBasedTextColor(mContext));
        holder.artistText.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
        holder.songTitleText.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
        holder.artistText.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
        convertView.setTag(holder);
    } else {
        holder = (QueueDrawerHolder) convertView.getTag();
    }
    //Get the song's basic info.
    SongHelper songHelper = new SongHelper();
    songHelper.populateBasicSongData(mContext, position);
    holder.songTitleText.setText(songHelper.getTitle());
    holder.artistText.setText(songHelper.getArtist());
    //Apply the item's colors.
    try {
        if (position == mApp.getService().getCurrentSongIndex()) {
            holder.songTitleText.setTextColor(mColors[0]);
            holder.artistText.setTextColor(mColors[0]);
        } else if (mApp.getCurrentTheme() == Common.LIGHT_THEME) {
            holder.songTitleText.setTextColor(UIElementsHelper.getThemeBasedTextColor(mContext));
            holder.artistText.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
        } else if (mApp.getCurrentTheme() == Common.DARK_THEME) {
            holder.songTitleText.setTextColor(UIElementsHelper.getThemeBasedTextColor(mContext));
            holder.artistText.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return convertView;
}
Also used : SongHelper(com.jams.music.player.Helpers.SongHelper)

Example 2 with SongHelper

use of com.jams.music.player.Helpers.SongHelper in project JamsMusicPlayer by psaravan.

the class AudioPlaybackService method prepareMediaPlayer.

/**
	 * Grabs the song parameters at the specified index, retrieves its 
	 * data source, and beings to asynchronously prepare mMediaPlayer. 
	 * Once mMediaPlayer is prepared, mediaPlayerPrepared is called.
	 * 
	 * @return True if the method completed with no exceptions. False, otherwise.
	 */
public boolean prepareMediaPlayer(int songIndex) {
    try {
        //Stop here if we're at the end of the queue.
        if (songIndex == -1)
            return true;
        //Reset mMediaPlayer to it's uninitialized state.
        getMediaPlayer().reset();
        //Loop the player if the repeat mode is set to repeat the current song.
        if (getRepeatMode() == Common.REPEAT_SONG) {
            getMediaPlayer().setLooping(true);
        }
        //Set mMediaPlayer's song data.
        SongHelper songHelper = new SongHelper();
        if (mFirstRun) {
            /*
	    		 * We're not preloading the next song (mMediaPlayer2 is not 
	    		 * playing right now). mMediaPlayer's song is pointed at 
	    		 * by mCurrentSongIndex.
	    		 */
            songHelper.populateSongData(mContext, songIndex);
            setMediaPlayerSongHelper(songHelper);
            //Set this service as a foreground service.
            startForeground(mNotificationId, buildNotification(songHelper));
        } else {
            songHelper.populateSongData(mContext, songIndex);
            setMediaPlayerSongHelper(songHelper);
        }
        /*
    		 * Set the data source for mMediaPlayer and start preparing it 
    		 * asynchronously.
    		 */
        getMediaPlayer().setDataSource(mContext, getSongDataSource(getMediaPlayerSongHelper()));
        getMediaPlayer().setOnPreparedListener(mediaPlayerPrepared);
        getMediaPlayer().setOnErrorListener(onErrorListener);
        getMediaPlayer().prepareAsync();
    } catch (Exception e) {
        Log.e("DEBUG", "MESSAGE", e);
        e.printStackTrace();
        //Display an error toast to the user.
        showErrorToast();
        //Add the current song index to the list of failed indeces.
        getFailedIndecesList().add(songIndex);
        //Start preparing the next song.
        if (!isAtEndOfQueue() || mFirstRun)
            prepareMediaPlayer(songIndex + 1);
        else
            return false;
        return false;
    }
    return true;
}
Also used : SongHelper(com.jams.music.player.Helpers.SongHelper)

Example 3 with SongHelper

use of com.jams.music.player.Helpers.SongHelper in project JamsMusicPlayer by psaravan.

the class PlaylistPagerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mContext = getActivity();
    mApp = (Common) mContext.getApplicationContext();
    mRootView = (ViewGroup) inflater.inflate(R.layout.fragment_playlist_pager_fill, container, false);
    mPosition = getArguments().getInt("POSITION");
    overflowIcon = (ImageView) mRootView.findViewById(R.id.now_playing_overflow_icon);
    coverArt = (ImageView) mRootView.findViewById(R.id.coverArt);
    bottomDarkPatch = (RelativeLayout) mRootView.findViewById(R.id.bottomDarkPatch);
    songInfoLayout = (RelativeLayout) mRootView.findViewById(R.id.songInfoLayout);
    songNameTextView = (TextView) mRootView.findViewById(R.id.songName);
    artistAlbumNameTextView = (TextView) mRootView.findViewById(R.id.artistAlbumName);
    mLyricsScrollView = (ScrollView) mRootView.findViewById(R.id.lyrics_scroll_view);
    mLyricsTextView = (TextView) mRootView.findViewById(R.id.lyrics);
    mLyricsEmptyTextView = (TextView) mRootView.findViewById(R.id.lyrics_empty);
    mLyricsTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
    mLyricsEmptyTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
    songNameTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
    artistAlbumNameTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
    //Allow the TextViews to scroll if they extend beyond the layout margins.
    songNameTextView.setSelected(true);
    artistAlbumNameTextView.setSelected(true);
    //Initialize the pop up menu.
    popup = new PopupMenu(getActivity(), overflowIcon);
    popup.getMenuInflater().inflate(R.menu.now_playing_overflow_menu, popup.getMenu());
    popup.setOnMenuItemClickListener(menuItemClickListener);
    mSongHelper = new SongHelper();
    mSongHelper.setAlbumArtLoadedListener(this);
    if (mApp.getOrientation() == Common.ORIENTATION_LANDSCAPE)
        mSongHelper.populateSongData(mContext, mPosition);
    else
        mSongHelper.populateSongData(mContext, mPosition, new PicassoMirrorReflectionTransformer());
    songNameTextView.setText(mSongHelper.getTitle());
    artistAlbumNameTextView.setText(mSongHelper.getAlbum() + " - " + mSongHelper.getArtist());
    overflowIcon.setOnClickListener(overflowClickListener);
    //Kitkat padding.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        int navigationBarHeight = Common.getNavigationBarHeight(mContext);
        int bottomPadding = songInfoLayout.getPaddingBottom();
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) bottomDarkPatch.getLayoutParams();
        if (navigationBarHeight > 0) {
            /* The nav bar already has padding, so remove the extra 15dp
                 * padding that was applied in the layout file.
                 */
            int marginPixelsValue = (int) mApp.convertDpToPixels(15, mContext);
            bottomPadding -= marginPixelsValue;
            params.height -= marginPixelsValue;
        }
        bottomPadding += navigationBarHeight;
        songInfoLayout.setPadding(0, 0, 0, bottomPadding);
        params.height += navigationBarHeight;
        bottomDarkPatch.setLayoutParams(params);
    }
    return mRootView;
}
Also used : RelativeLayout(android.widget.RelativeLayout) PicassoMirrorReflectionTransformer(com.jams.music.player.ImageTransformers.PicassoMirrorReflectionTransformer) SongHelper(com.jams.music.player.Helpers.SongHelper) PopupMenu(android.widget.PopupMenu)

Example 4 with SongHelper

use of com.jams.music.player.Helpers.SongHelper in project JamsMusicPlayer by psaravan.

the class AudioPlaybackService method prepareMediaPlayer2.

/**
	 * Grabs the song parameters at the specified index, retrieves its 
	 * data source, and beings to asynchronously prepare mMediaPlayer2. 
	 * Once mMediaPlayer2 is prepared, mediaPlayer2Prepared is called.
	 * 
	 * @return True if the method completed with no exceptions. False, otherwise.
	 */
public boolean prepareMediaPlayer2(int songIndex) {
    try {
        //Stop here if we're at the end of the queue.
        if (songIndex == -1)
            return true;
        //Reset mMediaPlayer2 to its uninitialized state.
        getMediaPlayer2().reset();
        //Loop the player if the repeat mode is set to repeat the current song.
        if (getRepeatMode() == Common.REPEAT_SONG) {
            getMediaPlayer2().setLooping(true);
        }
        //Set mMediaPlayer2's song data.
        SongHelper songHelper = new SongHelper();
        songHelper.populateSongData(mContext, songIndex);
        setMediaPlayer2SongHelper(songHelper);
        /*
    		 * Set the data source for mMediaPlayer and start preparing it 
    		 * asynchronously.
    		 */
        getMediaPlayer2().setDataSource(mContext, getSongDataSource(getMediaPlayer2SongHelper()));
        getMediaPlayer2().setOnPreparedListener(mediaPlayer2Prepared);
        getMediaPlayer2().setOnErrorListener(onErrorListener);
        getMediaPlayer2().prepareAsync();
    } catch (Exception e) {
        e.printStackTrace();
        //Display an error toast to the user.
        showErrorToast();
        //Add the current song index to the list of failed indeces.
        getFailedIndecesList().add(songIndex);
        //Start preparing the next song.
        if (!isAtEndOfQueue())
            prepareMediaPlayer2(songIndex + 1);
        else
            return false;
        return false;
    }
    return true;
}
Also used : SongHelper(com.jams.music.player.Helpers.SongHelper)

Aggregations

SongHelper (com.jams.music.player.Helpers.SongHelper)4 PopupMenu (android.widget.PopupMenu)1 RelativeLayout (android.widget.RelativeLayout)1 PicassoMirrorReflectionTransformer (com.jams.music.player.ImageTransformers.PicassoMirrorReflectionTransformer)1