app/src/main/java/com/smedic/tubtub/fragments/PlaylistsFragment.java
@Override
    public void onVideosReceived(ArrayList<YouTubeVideo> youTubeVideos) {
        //if playlist is empty, do not start service
        if (youTubeVideos.isEmpty()) {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    Toast.makeText(getContext(), "Playlist is empty!", Toast.LENGTH_SHORT).show();
                }
            });
        } else {
            Intent serviceIntent = new Intent(getContext(), BackgroundAudioService.class);
            serviceIntent.setAction(BackgroundAudioService.ACTION_PLAY);
            serviceIntent.putExtra(Config.YOUTUBE_TYPE, Config.YOUTUBE_MEDIA_TYPE_PLAYLIST);
            serviceIntent.putExtra(Config.YOUTUBE_TYPE_PLAYLIST, youTubeVideos);
            getActivity().startService(serviceIntent);
        }
    }
/**
     * Called when playlist video items are received
     *
     * @param youTubeVideos - list to be played in background service
     */
Called when playlist video items are received
@param youTubeVideos - list to be played in background service
Called when playlist video items are received @param youTubeVideos - list to be played in background service
@Override
    public void onVideosReceived(ArrayList<YouTubeVideo> youTubeVideos) {
        if (youTubeVideos.isEmpty()) {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    Toast.makeText(getContext(), "Playlist is empty!", Toast.LENGTH_SHORT).show();
                }
            });
        } else {
            Intent serviceIntent = new Intent(getContext(), BackgroundAudioService.class);
            serviceIntent.setAction(BackgroundAudioService.ACTION_PLAY);
            serviceIntent.putExtra(Config.YOUTUBE_TYPE, Config.YOUTUBE_MEDIA_TYPE_PLAYLIST);
            serviceIntent.putExtra(Config.YOUTUBE_TYPE_PLAYLIST, youTubeVideos);
            getActivity().startService(serviceIntent);
        }
    }
@ Override public void onVideosReceived ( ArrayList < YouTubeVideo > youTubeVideos ) { if ( youTubeVideos . isEmpty ( ) ) { getActivity ( ) . runOnUiThread ( new Runnable ( ) { public void run ( ) { Toast . makeText ( getContext ( ) , "Playlist is empty!" , Toast . LENGTH_SHORT ) . show ( ) ; } } ) ; } else { Intent serviceIntent = new Intent ( getContext ( ) , BackgroundAudioService . class ) ; serviceIntent . setAction ( BackgroundAudioService . ACTION_PLAY ) ; serviceIntent . putExtra ( Config . YOUTUBE_TYPE , Config . YOUTUBE_MEDIA_TYPE_PLAYLIST ) ; serviceIntent . putExtra ( Config . YOUTUBE_TYPE_PLAYLIST , youTubeVideos ) ; getActivity ( ) . startService ( serviceIntent ) ; } }
Called when playlist video items are received
 @param youTubeVideos - list to be played in background service
Called when playlist video items are received @param youTubeVideos - list to be played in background service
//if playlist is empty, do not start service