Open Kashish-Manandhar opened 3 years ago
What type of audio format are you using? local or online? If its online make sure the cache is turn off since if its on it will take some time to load before playing. If its offline you can try the app in production mode since reading/writing in debug mode is slower.
I am using the audio from the assets folder
In that case have you tired testing in production mode? If its still slow what is the time of loading?
What type of audio format are you using? local or online? If its online make sure the cache is turn off since if its on it will take some time to load before playing. If its offline you can try the app in production mode since reading/writing in debug mode is slower.
From where can I turn off the cache? any samples?
What type of audio format are you using? local or online? If its online make sure the cache is turn off since if its on it will take some time to load before playing. If its offline you can try the app in production mode since reading/writing in debug mode is slower.
From where can I turn off the cache? any samples?
Under Audio
there is a cache property. By default it is disabled.
What type of audio format are you using? local or online? If its online make sure the cache is turn off since if its on it will take some time to load before playing. If its offline you can try the app in production mode since reading/writing in debug mode is slower.
From where can I turn off the cache? any samples?
Under
Audio
there is a cache property. By default it is disabled.
Didn't help. Is this happening because of debug mode?
Can you provide some code sample and video
This is global.
library library.globals;
import 'package:assets_audio_player/assets_audio_player.dart';
class Player {
AssetsAudioPlayer player = AssetsAudioPlayer.withId('saylo_player');
static final Map<String, Player> _cache = {};
Player._createInstance();
factory Player() {
if (!_cache.containsKey("player")) {
Player instance = Player._createInstance();
_cache["player"] = instance;
instance.player.onErrorDo = (handler) {
handler.player.stop();
};
}
return _cache['player'];
}
}
AssetsAudioPlayer player = Player().player;
Inside Provider...
player.open(
Playlist(
audios: songs
.map<Audio>(
(song) => Audio.network(
song.songUrl,
metas: Metas(
id: song.id,
title: song.name,
artist: song.artist ?? "artist",
album: song.album ?? "album",
image: MetasImage.network(song.coverUrl),
),
),
)
.toList(),
),
showNotification: true,
autoStart: false,
);
player.play();
Also it plays twice sometimes. And can't stop without closing app.
This is global.
library library.globals; import 'package:assets_audio_player/assets_audio_player.dart'; class Player { AssetsAudioPlayer player = AssetsAudioPlayer.withId('saylo_player'); static final Map<String, Player> _cache = {}; Player._createInstance(); factory Player() { if (!_cache.containsKey("player")) { Player instance = Player._createInstance(); _cache["player"] = instance; instance.player.onErrorDo = (handler) { handler.player.stop(); }; } return _cache['player']; } } AssetsAudioPlayer player = Player().player;
Inside Provider...
player.open( Playlist( audios: songs .map<Audio>( (song) => Audio.network( song.songUrl, metas: Metas( id: song.id, title: song.name, artist: song.artist ?? "artist", album: song.album ?? "album", image: MetasImage.network(song.coverUrl), ), ), ) .toList(), ), showNotification: true, autoStart: false, ); player.play();
Also it plays twice sometimes. And can't stop without closing app.
Looks good to me, however you might wanna use auto start insead of manually calling play.
This is global.
library library.globals; import 'package:assets_audio_player/assets_audio_player.dart'; class Player { AssetsAudioPlayer player = AssetsAudioPlayer.withId('saylo_player'); static final Map<String, Player> _cache = {}; Player._createInstance(); factory Player() { if (!_cache.containsKey("player")) { Player instance = Player._createInstance(); _cache["player"] = instance; instance.player.onErrorDo = (handler) { handler.player.stop(); }; } return _cache['player']; } } AssetsAudioPlayer player = Player().player;
Inside Provider...
player.open( Playlist( audios: songs .map<Audio>( (song) => Audio.network( song.songUrl, metas: Metas( id: song.id, title: song.name, artist: song.artist ?? "artist", album: song.album ?? "album", image: MetasImage.network(song.coverUrl), ), ), ) .toList(), ), showNotification: true, autoStart: false, ); player.play();
Also it plays twice sometimes. And can't stop without closing app.
Looks good to me, however you might wanna use auto start insead of manually calling play.
Didn't work either.
player.open(
Playlist(
audios: songs
.map<Audio>(
(song) => Audio.network(
@Kashish-Manandhar are you using Audio.network
? if you're playing audio from assets folder like you mention - you might want to try Audio.file
ok i will try to use it
It feels like the player is starting to download and write the file and then start to play
Describe the feature you'd like A clear and concise description of what you want to happen.