Releases/January2014/src/src/org/nypl/adapter/ViewPagerAdapter.java
/**
	 * Function to play a song
	 * @param songIndex - index of song
	 * */
Function to play a song
@param songIndex - index of song
Function to play a song @param songIndex - index of song
public static void  playSong(String songIndex){
		String songTitle = null ;
		try {
			mp.reset();
			if(songIndex.contains("external") ){
				String  filePath ;
				Uri parcialUri = Uri.parse("content://media"+songIndex);
				Cursor cursor = mContext.getContentResolver().query(parcialUri, new String[] { android.provider.MediaStore.Audio.AudioColumns.DATA }, null, null, null);
				cursor.moveToFirst();   
				filePath = cursor.getString(0);
				mp.setDataSource(filePath);
				cursor.close();
			}else{
				mp.setDataSource(songIndex.trim());
			}
			songTitle=songIndex;
			mp.prepare();
			if(mp.getDuration()>Integer.parseInt(AudioDatalist.get(0).getClipFrom())*1000){
				PlaysDetailActivity.mAudiolayout.setVisibility(View.VISIBLE);
				Animation slideUp = setLayoutAnim_slideup(); 
				PlaysDetailActivity.mAudiolayout.startAnimation(slideUp);
				mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
			        @Override
			        public void onPrepared(MediaPlayer mp) {
			            mp.start();
			        }
			    });
			if(AudioDatalist!=null){
				mp.seekTo(Integer.parseInt(AudioDatalist.get(0).getClipFrom())*1000);
			}
			mp.start();
			PlaysDetailActivity.btnPlay.setImageResource(R.drawable.btn_pause);
			PlaysDetailActivity.songProgressBar.setProgress(0);
			PlaysDetailActivity.songProgressBar.setMax(100);
			updateProgressBar();	
			}else{
				PlaysDetailActivity.mAudiolayout.setVisibility(View.GONE);
				Toast.makeText(mContext, "Audio length is short. ", Toast.LENGTH_LONG).show();
				}
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalStateException e) {
			e.printStackTrace();
		} catch (IOException e) {
			PlaysDetailActivity.mAudiolayout.setVisibility(View.GONE);
			getAudio();			
			e.printStackTrace();
		}
	}
public static void playSong ( String songIndex ) { String songTitle = null ; try { mp . reset ( ) ; if ( songIndex . contains ( "external" ) ) { String filePath ; Uri parcialUri = Uri . parse ( "content://media" + songIndex ) ; Cursor cursor = mContext . getContentResolver ( ) . query ( parcialUri , new String [ ] { android . provider . MediaStore . Audio . AudioColumns . DATA } , null , null , null ) ; cursor . moveToFirst ( ) ; filePath = cursor . getString ( 0 ) ; mp . setDataSource ( filePath ) ; cursor . close ( ) ; } else { mp . setDataSource ( songIndex . trim ( ) ) ; } songTitle = songIndex ; mp . prepare ( ) ; if ( mp . getDuration ( ) > Integer . parseInt ( AudioDatalist . get ( 0 ) . getClipFrom ( ) ) * 1000 ) { PlaysDetailActivity . mAudiolayout . setVisibility ( View . VISIBLE ) ; Animation slideUp = setLayoutAnim_slideup ( ) ; PlaysDetailActivity . mAudiolayout . startAnimation ( slideUp ) ; mp . setOnPreparedListener ( new MediaPlayer . OnPreparedListener ( ) { @ Override public void onPrepared ( MediaPlayer mp ) { mp . start ( ) ; } } ) ; if ( AudioDatalist != null ) { mp . seekTo ( Integer . parseInt ( AudioDatalist . get ( 0 ) . getClipFrom ( ) ) * 1000 ) ; } mp . start ( ) ; PlaysDetailActivity . btnPlay . setImageResource ( R . drawable . btn_pause ) ; PlaysDetailActivity . songProgressBar . setProgress ( 0 ) ; PlaysDetailActivity . songProgressBar . setMax ( 100 ) ; updateProgressBar ( ) ; } else { PlaysDetailActivity . mAudiolayout . setVisibility ( View . GONE ) ; Toast . makeText ( mContext , "Audio length is short. " , Toast . LENGTH_LONG ) . show ( ) ; } } catch ( IllegalArgumentException e ) { e . printStackTrace ( ) ; } catch ( IllegalStateException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { PlaysDetailActivity . mAudiolayout . setVisibility ( View . GONE ) ; getAudio ( ) ; e . printStackTrace ( ) ; } }
Function to play a song
 @param songIndex - index of song
Function to play a song @param songIndex - index of song
// Play song ///songIndex.trim() //("content://media/external/audio/media/4743.mp3", new String[] { android.provider.MediaStore.Audio.AudioColumns.DATA }, null, null, null); //} // TODO Auto-generated method stub //mp.seekTo(0); ///