Last updated:
0 purchases
just audio media kit
just_audio_media_kit #
media_kit bindings for just_audio
Breaking changes in 2.x #
The installation process has changed, please re-read the install instructions.
Installation #
In your pubspec.yaml: #
dependencies:
just_audio_media_kit: ^2.0.0
# Select the native media_kit libs based on your usage:
# NOTE: if including video libs already, these audio libs aren't necessary.
media_kit_libs_linux: any
media_kit_libs_windows_audio: any
copied to clipboard
Note: you can also use just_audio_media_kit for Android, iOS and macOS by including the required libs (see below) and enable them in ensureInitialized(). However, this is not required as they're natively supported by just_audio.
Use mimalloc (from media-kit's README) #
You should consider replacing the default memory allocator with mimalloc for avoiding memory leaks.
This is as simple as adding one line to linux/CMakeLists.txt:
target_link_libraries(${BINARY_NAME} PRIVATE ${MIMALLOC_LIB})
copied to clipboard
Before using the AudioPlayer, call #
// by default, windows and linux are enabled
JustAudioMediaKit.ensureInitialized();
// or, if you want to manually configure enabled platforms instead:
// make sure to include the required dependency in pubspec.yaml for
// each enabled platform!
JustAudioMediaKit.ensureInitialized(
linux: true, // default: true - dependency: media_kit_libs_linux
windows: true, // default: true - dependency: media_kit_libs_windows_audio
android: true, // default: false - dependency: media_kit_libs_android_audio
iOS: true, // default: false - dependency: media_kit_libs_ios_audio
macOS: true, // default: false - dependency: media_kit_libs_macos_audio
);
copied to clipboard
Now you can use just_audio's AudioPlayer as normal!
Plugin-specific configuration (settings for media_kit's Player() instance) #
NOTE: these must be set the player initializes or they won't work (you can set these right after or before calling ensureInitialized)!
Set MPV's log level. Default: MPVLogLevel.error
JustAudioMediaKit.mpvLogLevel = MPVLogLevel.debug;
copied to clipboard
Sets the demuxer's cache size (in bytes). Default: 32 * 1024 * 1204 (32 MB)
JustAudioMediaKit.bufferSize = 8 * 1024 * 1024; // 8 MB
copied to clipboard
Sets the name of the underlying window and process for native backend. This is visible, for example, inside the Windows' volume mixer or also in pavucontrol on Linux. Default: 'JustAudioMediaKit'
JustAudioMediaKit.title = 'My Audio Player App';
copied to clipboard
Sets the list of allowed protocols for native backend. Default: ['udp', 'rtp', 'tcp', 'tls', 'data', 'file', 'http', 'https', 'crypto']
IF YOU EDIT THIS OPTION: Remember that file is needed for playing local files, https and http are needed to play from URLs and http to play from a StreamAudioSource (and sources that implement it, like LockCachingAudioSource).
JustAudioMediaKit.protocolWhitelist = const ['http', 'https'];
copied to clipboard
Enables or disables pitch shift control for native backend (with this set to false, setPitch won't work). Default: true
JustAudioMediaKit.pitch = true;
copied to clipboard
Enables gapless playback via the --prefetch-playlist in libmpv. Default: false
This is highly experimental. Use at your own risk.
Check mpv's docs and
the related issue for more information
JustAudioMediaKit.prefetchPlaylist = true;
copied to clipboard
Manually specify libmpv path (ADVANCED) #
To manually specify the libmpv path, you can use the libmpv parameter in the ensureInitialized method:
JustAudioMediaKit.ensureInitialized(
libmpv: '/usr/lib/libmpv.so.2',
);
copied to clipboard
This is NOT NEEDED in most cases, as package:media_kit will choose the right library for you (and can even bundle libmpv via the media_kit_libs_*_* packages). If you choose to use this option, you will have to perform checks about what platform you're on and where libmpv is located in that specific platform.
Features #
Feature
Linux, Windows
read from URL
✅
read from file
✅
read from asset
✅
read from byte stream
✅*
request headers
✅ (untested)
DASH
✅ (untested)
HLS
✅ (untested)
ICY metadata
buffer status/position
✅
play/pause/seek
✅
set volume/speed
✅
clip audio
playlists
✅
looping/shuffling
✅
compose audio
gapless playback
✅**
report player errors
✅
handle phonecall interruptions
buffering/loading options
set pitch
✅
skip silence
equalizer
volume boost
* reads from byte stream via a local HTTP server provided by just_audio
** needs to be enabled
Caveats #
just_audio's shuffleOrder is currently ignored, because there doesn't seem to be a straightforward way to implement it: because of this, I recommend implementing shuffle by manually shuffling the queue, create a new ConcatenatingAudioSource and use setAudioSource on your player object.
ClippingAudioSource is currently not supported (waiting for media-kit/media-kit#581 to be released)
The plugin hasn't been tested with multiple player instances, though it should work without any issues.
Licensing #
This package is licensed under the Unlicense license, though
please note that package:media_kit (which is a direct dependency of this package) is licensed under the MIT license.
So please refer to package:media_kit for potential licensing issues.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.