MCPcopy Index your code
hub / github.com/CodeBoy722/MediaFacer

github.com/CodeBoy722/MediaFacer @1.0.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.0.3 ↗ · + Follow
380 symbols 946 edges 38 files 22 documented · 6%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

1 ARUJ1yzwjpDp1aRX7oZrwQ

MediaFacer

An android library for the structured querying of the MediaStore to get media files in the simplest way possible taking in account both storage mediums on device

Read the article on Medium

Download

To include MediaFacer in your project, your project should have minSdkVersion 19 and above.

You can download a jar from GitHub's releases page.

Or use Gradle: Add it in your your projects root build.gradle file

 allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }   

Add the dependency in the app level build.gradle file

dependencies {
       implementation 'com.github.CodeBoy722:MediaFacer:1.0.2'
    }

Usage

The MediaFacer library already contains a set of classes for holding audio,video and image file data and each time a query is executed to get media files, the results always come in anyone of these classes.

videoContent :this class holds data for a specific video file.

audioContent : this class holds data for a specific audio file.

pictureContent : this class holds data for a specific image file.

audioAlbumContent : this class holds all audio files and data which are related to the same music album.

audioArtistContent : this class holds all audio files and data related to the same music Artist.

audioFolderContent : this class holds all audio files found in the same folder on the storage mediums.

pictureFolderContent : this class holds all image files found in the same folder on the storage mediums.

videoFolderContent : this class holds all video files found in the same folder on the storage mediums.

Getting audio files from the MediaStore

get all audio files

ArrayList<audioContent> audioContents;
audioContents = MediaFacer
                .withAudioContex(mContext)
                .getAllAudioContent(AudioGet.externalContentUri;

setting and playing audio in MediaPlayer object from audioContent class

Uri content = Uri.parse(audioContent.getAssetFileStringUri());
try {
            AssetFileDescriptor file = getActivity().getContentResolver().openAssetFileDescriptor(content, "r");
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                player.setDataSource(file);
            }else {
                player.setDataSource(audioContent.getFilePath());
            }
            player.setLooping(false);
            player.prepare();
            player.start();
        } catch (Exception e) {
            e.printStackTrace();
}

get all audio files with similar albums

ArrayList<audioAlbumContent>  allAlbums;
    allAlbums = MediaFacer
                .withAudioContex(mContext)
                .getAllAlbums(AudioGet.externalContentUri);

get all audio files with similar artists

ArrayList<audioArtistContent> allArtists;

    ArrayList<String> ids = MediaFacer
                            .withAudioContex(mContext)
                            .getAllArtistIds(AudioGet.externalContentUri);

    allArtists = MediaFacer
                 .withAudioContex(mContext)
                 .getAllArtists(ids,AudioGet.externalContentUri);

get all audio files in same folders

 ArrayList<audioFolderContent> buckets;
 buckets = MediaFacer
           .withAudioContex(mContext)
           .getAllAudioFolderContent();

Getting images from the MediaStore

get all images in the MediaStore.

ArrayList<pictureContent> allPhotos;

  allPhotos = MediaFacer
              .withPictureContex(mContext)
              .getAllPictureContents(PictureGet.externalContentUri);

loading and displaying images from pictureContent class, you can use Glide for this

ImageView picture = findViewById(R.id.picture);
Glide.with(mContext)
                    .load(Uri.parse(pictureContent.getAssertFileStringUri()))
                    .apply(new RequestOptions().centerCrop())
                    .into(picture);

get all folders containing pictures

ArrayList<pictureFolderContent> pictureFolders = new ArrayList<>();

      pictureFolders.addAll(MediaFacer.withPictureContex(mContext).getPictureFolders());

//now load images for the first pictureFolderContent object
    pictureFolders.get(0)
    .setPhotos(MediaFacer
    .withPictureContex(mContext)
    .getAllPictureContentByBucket_id(pictureFolders.get(0).getBucket_id()); 

Getting Videos from the MediaStore

get all videos in the MediaStore.

ArrayList<videoContent> allVideos;
 allVideos = MediaFacer
             .withVideoContex(mContext)
             .getAllVideoContent(VideoGet.externalContentUri);

loading video into VideoView from videoContent class

VideoView playZone findViewById(R.id.vid_zone);
SeekBar seeker = findViewById(R.id.seeker);

 playZone.setVideoURI(Uri.parse(videoContent.getAssetFileStringUri()));
        playZone.requestFocus();
        seeker.setMax((int) videos.get(position).getVideoDuration());
        playZone.start();

get all folders containing videos

 ArrayList<videoFolderContent> videoFolders = new ArrayList<>();

     videoFolders.addAll(MediaFacer.withVideoContex(mContext).getVideoFolders(VideoGet.externalContentUri));

//now load videos for the first videoFolderContent object
    videoFolders.get(0)
    .setVideoFiles(MediaFacer.withVideoContex(mContext)
    .getAllVideoContentByBucket_id(videoFolders.get(0).getBucket_id());

Extension points exported contracts — how you extend this code

musicActionListerner (Interface)
(no doc) [2 implementers]
app/src/main/java/com/CodeBoy/MediaFacer_Examples/adapters/audioRecycleAdapter.java
pictureActionListrener (Interface)
(no doc) [1 implementers]
app/src/main/java/com/CodeBoy/MediaFacer_Examples/adapters/imageRecycleAdapter.java
videoActionListener (Interface)
(no doc) [1 implementers]
app/src/main/java/com/CodeBoy/MediaFacer_Examples/adapters/videoRecycleAdapter.java
folderListener (Interface)
(no doc) [1 implementers]
app/src/main/java/com/CodeBoy/MediaFacer_Examples/adapters/audioBucketAdapter.java
artistListener (Interface)
(no doc) [1 implementers]
app/src/main/java/com/CodeBoy/MediaFacer_Examples/adapters/audioArtistsAdapter.java

Core symbols most depended-on inside this repo

size
called by 27
mediafacer/src/main/java/com/CodeBoy/MediaFacer/mediaDataCalculator.java
setDate_added
called by 16
mediafacer/src/main/java/com/CodeBoy/MediaFacer/mediaHolders/audioContent.java
setDate_modified
called by 16
mediafacer/src/main/java/com/CodeBoy/MediaFacer/mediaHolders/audioContent.java
setDate_added
called by 12
mediafacer/src/main/java/com/CodeBoy/MediaFacer/mediaHolders/videoContent.java
getVideoDuration
called by 11
mediafacer/src/main/java/com/CodeBoy/MediaFacer/mediaHolders/videoContent.java
setMusicSize
called by 9
mediafacer/src/main/java/com/CodeBoy/MediaFacer/mediaHolders/audioContent.java
setDate_added
called by 9
mediafacer/src/main/java/com/CodeBoy/MediaFacer/mediaHolders/pictureContent.java
getAssetFileStringUri
called by 8
mediafacer/src/main/java/com/CodeBoy/MediaFacer/mediaHolders/videoContent.java

Shape

Method 324
Class 50
Interface 6

Languages

Java100%

Modules by API surface

mediafacer/src/main/java/com/CodeBoy/MediaFacer/mediaHolders/audioContent.java28 symbols
mediafacer/src/main/java/com/CodeBoy/MediaFacer/mediaHolders/videoContent.java24 symbols
mediafacer/src/main/java/com/CodeBoy/MediaFacer/mediaHolders/pictureContent.java18 symbols
mediafacer/src/main/java/com/CodeBoy/MediaFacer/mediaHolders/audioAlbumContent.java16 symbols
app/src/main/java/com/CodeBoy/MediaFacer_Examples/fragments/videoPlayerFragment.java16 symbols
app/src/main/java/com/CodeBoy/MediaFacer_Examples/adapters/videoRecycleAdapter.java14 symbols
app/src/main/java/com/CodeBoy/MediaFacer_Examples/adapters/imageRecycleAdapter.java14 symbols
app/src/main/java/com/CodeBoy/MediaFacer_Examples/adapters/audioRecycleAdapter.java14 symbols
mediafacer/src/main/java/com/CodeBoy/MediaFacer/AudioGet.java13 symbols
app/src/main/java/com/CodeBoy/MediaFacer_Examples/fragments/fragmentAudioContents.java13 symbols
app/src/main/java/com/CodeBoy/MediaFacer_Examples/adapters/audioBucketAdapter.java12 symbols
app/src/main/java/com/CodeBoy/MediaFacer_Examples/adapters/audioArtistsAdapter.java12 symbols

For agents

$ claude mcp add MediaFacer \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact