app/src/main/java/com/smedic/tubtub/BackgroundAudioService.java
private void handleMedia(Intent intent) {
        int intentMediaType = intent.getIntExtra(Config.YOUTUBE_TYPE, Config.YOUTUBE_MEDIA_NO_NEW_REQUEST);
        switch (intentMediaType) {
            case Config.YOUTUBE_MEDIA_NO_NEW_REQUEST: //video is paused,so no new playback requests should be processed
                mMediaPlayer.start();
                break;
            case Config.YOUTUBE_MEDIA_TYPE_VIDEO:
                mediaType = Config.YOUTUBE_MEDIA_TYPE_VIDEO;
                videoItem = (YouTubeVideo) intent.getSerializableExtra(Config.YOUTUBE_TYPE_VIDEO);
                if (videoItem.getId() != null) {
                    playVideo();
                }
                break;
            case Config.YOUTUBE_MEDIA_TYPE_PLAYLIST: //new playlist playback request
                mediaType = Config.YOUTUBE_MEDIA_TYPE_PLAYLIST;
                youTubeVideos = (ArrayList<YouTubeVideo>) intent.getSerializableExtra(Config.YOUTUBE_TYPE_PLAYLIST);
                int startPosition = intent.getIntExtra(Config.YOUTUBE_TYPE_PLAYLIST_VIDEO_POS, 0);
                iterator = youTubeVideos.listIterator(startPosition);
                playNext();
                break;
            default:
                Log.d(TAG, "Unknown command");
                break;
        }
    }
/**
     * Handles media - playlists and videos sent from fragments
     *
     * @param intent
     */
Handles media - playlists and videos sent from fragments
@param intent
Handles media - playlists and videos sent from fragments @param intent
private void handleMedia(Intent intent) {
        int intentMediaType = intent.getIntExtra(Config.YOUTUBE_TYPE, Config.YOUTUBE_MEDIA_NO_NEW_REQUEST);
        switch (intentMediaType) {
            case Config.YOUTUBE_MEDIA_NO_NEW_REQUEST: 
                mMediaPlayer.start();
                break;
            case Config.YOUTUBE_MEDIA_TYPE_VIDEO:
                mediaType = Config.YOUTUBE_MEDIA_TYPE_VIDEO;
                videoItem = (YouTubeVideo) intent.getSerializableExtra(Config.YOUTUBE_TYPE_VIDEO);
                if (videoItem.getId() != null) {
                    playVideo();
                }
                break;
            case Config.YOUTUBE_MEDIA_TYPE_PLAYLIST: 
                mediaType = Config.YOUTUBE_MEDIA_TYPE_PLAYLIST;
                youTubeVideos = (ArrayList<YouTubeVideo>) intent.getSerializableExtra(Config.YOUTUBE_TYPE_PLAYLIST);
                int startPosition = intent.getIntExtra(Config.YOUTUBE_TYPE_PLAYLIST_VIDEO_POS, 0);
                iterator = youTubeVideos.listIterator(startPosition);
                playNext();
                break;
            default:
                Log.d(TAG, "Unknown command");
                break;
        }
    }
private void handleMedia ( Intent intent ) { int intentMediaType = intent . getIntExtra ( Config . YOUTUBE_TYPE , Config . YOUTUBE_MEDIA_NO_NEW_REQUEST ) ; switch ( intentMediaType ) { case Config . YOUTUBE_MEDIA_NO_NEW_REQUEST : mMediaPlayer . start ( ) ; break ; case Config . YOUTUBE_MEDIA_TYPE_VIDEO : mediaType = Config . YOUTUBE_MEDIA_TYPE_VIDEO ; videoItem = ( YouTubeVideo ) intent . getSerializableExtra ( Config . YOUTUBE_TYPE_VIDEO ) ; if ( videoItem . getId ( ) != null ) { playVideo ( ) ; } break ; case Config . YOUTUBE_MEDIA_TYPE_PLAYLIST : mediaType = Config . YOUTUBE_MEDIA_TYPE_PLAYLIST ; youTubeVideos = ( ArrayList < YouTubeVideo > ) intent . getSerializableExtra ( Config . YOUTUBE_TYPE_PLAYLIST ) ; int startPosition = intent . getIntExtra ( Config . YOUTUBE_TYPE_PLAYLIST_VIDEO_POS , 0 ) ; iterator = youTubeVideos . listIterator ( startPosition ) ; playNext ( ) ; break ; default : Log . d ( TAG , "Unknown command" ) ; break ; } }
Handles media - playlists and videos sent from fragments
 @param intent
Handles media - playlists and videos sent from fragments @param intent
//video is paused,so no new playback requests should be processed //new playlist playback request