All Projects → yangwencan2002 → Medialoader

yangwencan2002 / Medialoader

Licence: apache-2.0
Cache video/audio while playing for any android media player

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Medialoader

Sjnetwork
SJNetwork is a high level network request tool based on AFNetworking and inspired on YTKNetwork.
Stars: ✭ 231 (+138.14%)
Mutual labels:  cache, download
Ktvhttpcache
A powerful media cache framework.
Stars: ✭ 2,113 (+2078.35%)
Mutual labels:  cache, audio
Scdlbot
Telegram Bot for downloading MP3 rips of tracks/sets from SoundCloud, Bandcamp, YouTube with tags and artwork.
Stars: ✭ 210 (+116.49%)
Mutual labels:  audio, download
Youtube explode dart
Port of YoutubeExplode to dart
Stars: ✭ 76 (-21.65%)
Mutual labels:  audio, download
Net
Android上强大的网络请求
Stars: ✭ 344 (+254.64%)
Mutual labels:  cache, download
Fwplayer
A video player SDK for iOS, it is based on AVPlayer. https://se.linkedin.com/in/foks-huiwang, https://fokswang.wixsite.com/home
Stars: ✭ 321 (+230.93%)
Mutual labels:  cache, audio
Q Municate Ios
Q-municate iOS repository
Stars: ✭ 164 (+69.07%)
Mutual labels:  cache, audio
Daisynet
1. - Alamofire与Cache封装 , 更容易存储请求数据. 2. - 封装Alamofire下载,使用更方便
Stars: ✭ 331 (+241.24%)
Mutual labels:  cache, download
Ytmdl Web V2
Web version of ytmdl. Allows downloading songs with metadata embedded from various sources like itunes, gaana, LastFM etc.
Stars: ✭ 398 (+310.31%)
Mutual labels:  audio, download
Sjmediacacheserver
A HTTP Media Caching Framework. It can cache FILE or HLS media. 音视频边播边缓存框架, 支持 HLS(m3u8) 和 FILE(mp4, mp3等).
Stars: ✭ 87 (-10.31%)
Mutual labels:  cache, audio
Okhttps
如艺术一般优雅,像 1、2、3 一样简单,前后端通用,轻量却强大的 HTTP 客户端(同时支持 WebSocket 与 Stomp 协议)
Stars: ✭ 92 (-5.15%)
Mutual labels:  download
Neardb
Simple document db made for infinitely scalable globally distributed reads.
Stars: ✭ 92 (-5.15%)
Mutual labels:  cache
Processing Sound
Audio library for Processing built with JSyn
Stars: ✭ 94 (-3.09%)
Mutual labels:  audio
Egocache
Fast Caching for Objective-C (iPhone & Mac Compatible)
Stars: ✭ 1,339 (+1280.41%)
Mutual labels:  cache
Next Offline
make your Next.js application work offline using service workers via Google's workbox
Stars: ✭ 1,306 (+1246.39%)
Mutual labels:  cache
React Cassette Player
Simple ReactJS HTML5 audio player component built with SVG icons from The Noun Project.
Stars: ✭ 93 (-4.12%)
Mutual labels:  audio
Soundpusher
Virtual audio device, real-time encoder and SPDIF forwarder for macOS
Stars: ✭ 91 (-6.19%)
Mutual labels:  audio
Segan Pytorch
SEGAN pytorch implementation https://arxiv.org/abs/1703.09452
Stars: ✭ 91 (-6.19%)
Mutual labels:  audio
Backgroundmusic
Background Music, a macOS audio utility: automatically pause your music, set individual apps' volumes and record system audio.
Stars: ✭ 10,652 (+10881.44%)
Mutual labels:  audio
Vmtouch
Portable file system cache diagnostics and control
Stars: ✭ 1,341 (+1282.47%)
Mutual labels:  cache

logo

MediaLoader

Build Status Download License

简体中文README

Table of Content

Introduction

MediaLoader allow you to enable cache video/audio while playing for any android media player with single line code.

Features

  • caching to disk while streaming,no wait;
  • offline work with cached data,no download again;
  • working with any media player on android(MediaPlayer,VideoView,ExoPlayer,ijkplayer...);
  • cache management(cache dir change,cache file rename,max cache files size limit, max cache files count limit...);
  • pre-download available,can pre-download the audio/video to avoid waiting.

Quick start

Just add dependency (MediaLoader was released in jcenter):

dependencies {
    compile 'com.vincan:medialoader:1.0.0'
}

and use new url from MediaLoader instead of original url:

String proxyUrl = MediaLoader.getInstance(getContext()).getProxyUrl(VIDEO_URL);
videoView.setVideoPath(proxyUrl);

Usage

Listen downloading status

Add callback to listen downloading status:

MediaLoader.addDownloadListener(String url, DownloadListener listener)

don't forget to remove listener to avoid memory leaks:

MediaLoader.removeDownloadListener(String url, DownloadListener listener)

Change initial configuration

You can change the default initial configuration with help of MediaLoaderConfig:

        MediaLoaderConfig mediaLoaderConfig = new MediaLoaderConfig.Builder(this)
                .cacheRootDir(DefaultConfigFactory.createCacheRootDir(this, "your_cache_dir"))//directory for cached files
                .cacheFileNameGenerator(new HashCodeFileNameCreator())//names for cached files
                .maxCacheFilesCount(100)//max files count
                .maxCacheFilesSize(100 * 1024 * 1024)//max files size
                .maxCacheFileTimeLimit(5 * 24 * 60 * 60)//max file time
                .downloadThreadPoolSize(3)//download thread size
                .downloadThreadPriority(Thread.NORM_PRIORITY)//download thread priority
                .build();
        MediaLoader.getInstance(this).init(mediaLoaderConfig);

Pre-download

Sometimes the MediaLoader doesn't work good in the case of poor network.So pre-download audio/video is a good idea to avoid no sense of waiting. DownloadManager is a good partner of MediaLoader.

Just use DownloadManager.enqueue(Request request, DownloadListener listener) to start and DownloadManager.stop(String url) to stop pre-downloading.

More useful method such as pause,resume and so on are available in DownloadManager.

See API list for more details.

Documentation

MediaLoader

desc API
get MediaLoader instance MediaLoader#getInstance(Context context)
initialize MediaLoader MediaLoader#init(MediaLoaderConfig mediaLoaderConfig)
get proxy url MediaLoader#getProxyUrl(String url)
is file cached MediaLoader#isCached(String url)
get cache file MediaLoader#getCacheFile(String url)
add download listener MediaLoader#addDownloadListener(String url, DownloadListener listener)
remove download listener MediaLoader#removeDownloadListener(String url, DownloadListener listener)
remove download listener MediaLoader#removeDownloadListener(DownloadListener listener)
pause download MediaLoader#pauseDownload(String url)
resume download MediaLoader#resumeDownload(String url)
destroy MediaLoader instance MediaLoader#destroy()

MediaLoaderConfig.Builder

desc API
set cache root dir MediaLoaderConfig.Builder#cacheRootDir(File file)
set cache file name generator MediaLoaderConfig.Builder#cacheFileNameGenerator(FileNameCreator fileNameCreator)
set max cache files size MediaLoaderConfig.Builder#maxCacheFilesSize(long size)
set max cache files count MediaLoaderConfig.Builder#maxCacheFilesCount(int count)
set max cache file time MediaLoaderConfig.Builder#maxCacheFileTimeLimit(long timeLimit)
set download thread pool size MediaLoaderConfig.Builder#downloadThreadPoolSize(int threadPoolSize)
set download thread priority MediaLoaderConfig.Builder#downloadThreadPriority(int threadPriority)
set download ExecutorService MediaLoaderConfig.Builder#downloadExecutorService(ExecutorService executorService)
new MediaLoaderConfig instance MediaLoaderConfig.Builder#build()

DownloadManager

desc API
get MediaLoader instance DownloadManager#getInstance(Context context)
start download DownloadManager#enqueue(Request request)
start download DownloadManager#enqueue(Request request, DownloadListener listener)
is download task running DownloadManager#isRunning(String url)
pause download DownloadManager#pause(String url)
resume download DownloadManager#resume(String url)
stop download DownloadManager#stop(String url)
pause all download DownloadManager#pauseAll()
resume all download DownloadManager#resumeAll()
stop all download DownloadManager#stopAll()
is file cached DownloadManager#isCached(String url)
get cache file DownloadManager#getCacheFile(String url)
clean cache dir DownloadManager#cleanCacheDir()

Sample

See sample project.
image image

FAQ

1.What is the default initial configuration for MediaLoader?

config key default value
cache dir sdcard/Android/data/${application package}/cache/medialoader
cache file naming MD5(url)
max cache files count 500
max cache files size 500* 1024 * 1024(500M)
max cache file time 10 * 24 * 60 * 60(10 days)
download thread pool size 3
download thread priority Thread.MAX_PRIORITY

Change log

See release notes

Where released

See bintray.com

Support

Any problem?

  1. Learn more from sample.
  2. Read the source code.
  3. New issue.
  4. Contact us for help.

License

MediaLoader is under the Apache-2.0 license. See the LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].