Android Open Source - simpleplayer Media File Util






From Project

Back to project page simpleplayer.

License

The source code is released under:

GNU General Public License

If you think the Android project simpleplayer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.sergez.splayer.util;
//from w w w. j av a2  s.  c o  m
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import android.util.Log;

import java.io.File;

/**
 * @author Sergii Zhuk
 *         Date: 13.10.13
 *         Time: 14:07
 */
public class MediaFileUtil {
  private final static String TAG = MediaFileUtil.class.getSimpleName();

  public static MediaFileData loadMediaFileData(Context context, File file) {
    MediaFileData result;

    // start of the file playing - get all track duration as time left
    String selection = MediaStore.Audio.Media.DATA + " like ?";
    // Some  audio may be explicitly marked as not being music !=  0
    String[] selectionArgs = {file.getAbsolutePath() + "%"};
    String[] projection = {
        MediaStore.Audio.Media.ARTIST,
        MediaStore.Audio.Media.TITLE,
    };
    Uri uri = MediaStore.Audio.Media.getContentUriForPath(file.getAbsolutePath());
    Cursor cursor = context.getContentResolver().query(uri, projection,
        selection, selectionArgs, null);

    if ((cursor != null) && (cursor.moveToFirst())) {
      result = new MediaFileData(cursor.getString(0), cursor.getString(1));
    } else {
      Log.e(TAG, "Cursor is null or empty for file" + file.getAbsolutePath());
      result = new MediaFileData("", "");
    }
    cursor.close();
    return result;
  }

}




Java Source Code List

org.sergez.splayer.activity.AnimationMakeGoneListener.java
org.sergez.splayer.activity.AudioFxDemo.java
org.sergez.splayer.activity.DonationActivity.java
org.sergez.splayer.activity.ListData.java
org.sergez.splayer.activity.PlayFileAdapter.java
org.sergez.splayer.activity.PreferencesActivity.java
org.sergez.splayer.activity.SimplePlayerActivity.java
org.sergez.splayer.enums.RepeatState.java
org.sergez.splayer.enums.ShuffleState.java
org.sergez.splayer.inappbilling.Base64DecoderException.java
org.sergez.splayer.inappbilling.Base64.java
org.sergez.splayer.inappbilling.IabException.java
org.sergez.splayer.inappbilling.IabHelper.java
org.sergez.splayer.inappbilling.IabResult.java
org.sergez.splayer.inappbilling.Inventory.java
org.sergez.splayer.inappbilling.Purchase.java
org.sergez.splayer.inappbilling.Security.java
org.sergez.splayer.inappbilling.SkuDetails.java
org.sergez.splayer.service.SimplePlayerService.java
org.sergez.splayer.util.Constants.java
org.sergez.splayer.util.DialogUtils.java
org.sergez.splayer.util.DurationAlbumID.java
org.sergez.splayer.util.FileFormat.java
org.sergez.splayer.util.MediaFileData.java
org.sergez.splayer.util.MediaFileUtil.java
org.sergez.splayer.util.PlayerState.java
org.sergez.splayer.util.PrefsConstants.java
org.sergez.splayer.util.PrefsController.java
org.sergez.splayer.util.SortIgnoreCase.java
org.sergez.splayer.util.UIStateController.java
org.sergez.splayer.util.Utils.java
org.sergez.splayer.view.ScrollingTextView.java