Closed Azandowski closed 4 years ago
you're running the sample main.dart ?
No, I wrote my own. it worked only yesterday and now just do not. Now I tried install former version but still crashes
do you need code?
yes please
import 'dart:async'; import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:assets_audio_player/assets_audio_player.dart'; import 'package:flutter/material.dart'; import 'player/importPlayer.dart'; import 'player/PositionSeekWidget.dart'; import 'player/SongsSelector.dart'; import 'provider_data.dart'; import 'package:provider/provider.dart'; import 'models/DezzerData.dart'; import 'package:korshi/Login.dart'; List
}));
super.initState();
}
Future
if(assetsAudioPlayer.current.value != null){
}else{
print('something');
assetsAudioPlayer.open(Playlist(audios: audios),showNotification: true,autoStart: false);
}
// _assetsAudioPlayer.open(Playlist(audios: audios),showNotification: true,autoStart: false); return DezzerData.fromJson(json.decode(response.body)); }else{ print('baaaaaan'); return null; } }catch(e) { print(e); } }
Audio find(List
@override
Widget build(BuildContext context) {
var provide = Provider.of
Stack(
fit: StackFit.passthrough,
children: <Widget>[
PlayerBuilder.current(
player: assetsAudioPlayer,
builder: (BuildContext context, Playing playing) {
if (playing != null) {
final myAudio = find(this.audios, playing.audio.assetAudioPath);
return Container(
height: height/2.5,
child: Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(myAudio.metas.image.path), fit: BoxFit.cover)),
),
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.black.withOpacity(0.5), Colors.black],
begin: Alignment.topCenter,
end: Alignment.bottomCenter),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: Column(
children: <Widget>[
SizedBox(height: 52.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
GestureDetector(
child: Container(
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.1),
borderRadius: BorderRadius.circular(50.0)),
child: Icon(
Icons.arrow_back_ios,
color: Colors.white,
),
),
onTap: (){
Navigator.pop(context);
},
),
Container(
child: Text(
' 😍TOP 30 песен с Dezzer 😍',style: TextStyle(color: Colors.white,fontFamily: 'Mont'),
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
color: Colors.black54
),
padding: EdgeInsets.symmetric(horizontal: 8,vertical: 4),
)
],
),
Spacer(),
Text(myAudio.metas.title,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 32.0)),
SizedBox(
height: 6.0,
),
Text(
myAudio.metas.artist,
style: TextStyle(
color: Colors.white.withOpacity(0.6),
fontSize: 18.0),
),
SizedBox(height: 16.0),
],
),
)
],
),
);
}
return SizedBox();
},
),
],
),
SizedBox(
height: 20,
),
PlayerBuilder.current(
player: assetsAudioPlayer,
builder: (context, playing) {
if (playing == null) {
return SizedBox();
}
return Column(
children: <Widget>[
PlayerBuilder.isLooping(
player: assetsAudioPlayer,
builder: (context, isLooping) {
return PlayerBuilder.isPlaying(
player: assetsAudioPlayer,
builder: (context, isPlaying) {
return PlayingControls(
isLooping: isLooping,
isPlaying: isPlaying,
isPlaylist: true,
toggleLoop: () {
assetsAudioPlayer.toggleLoop();
},
onPlay: () {
assetsAudioPlayer.playOrPause();
},
onNext: () {
//_assetsAudioPlayer.forward(Duration(seconds: 10));
assetsAudioPlayer.next();
},
onPrevious: () {
assetsAudioPlayer.previous();
},
);
});
},
),
PlayerBuilder.realtimePlayingInfos(
player: assetsAudioPlayer,
builder: (context, infos) {
if (infos == null) {
return SizedBox();
}
//print("infos: $infos");
return Column(
children: [
PositionSeekWidget(
currentPosition: infos.currentPosition,
duration: infos.duration,
seekTo: (to) {
assetsAudioPlayer.seek(to);
},
),
],
);
}),
],
);
}),
Expanded(
child: PlayerBuilder.current(
player: assetsAudioPlayer,
builder: (BuildContext context, Playing playing) {
return SongsSelector(
audios: audios,
onPlaylistSelected: (myAudios) {
assetsAudioPlayer.open(
Playlist(audios: myAudios),
showNotification: true,
);
},
onSelected: (myAudio) {
assetsAudioPlayer.open(Playlist(audios: audios,startIndex: myAudio));
},
playing: playing,
);
}),
),
PlayerBuilder.volume(
player: assetsAudioPlayer,
builder: (context, volume) {
return VolumeSelector(
volume: volume,
onChange: (v) {
assetsAudioPlayer.setVolume(v);
},
);
}),
PlayerBuilder.playSpeed(
player: assetsAudioPlayer,
builder: (context, playSpeed) {
return PlaySpeedSelector(
playSpeed: playSpeed,
onChange: (v) {
assetsAudioPlayer.setPlaySpeed(v);
},
);
}),
],
),
)
: Center(
child: CircularProgressIndicator(
backgroundColor: Colors.red, strokeWidth: 5),
);
}
),
),
);
} }
do you have a stacktrace of your error ?
no, how to get that?
Also what is the difference between network and livestream if you use the same links for both?
network : pause/play will resume when you paused livestream: pause/play will resume in the present stream (you will loose what's behind the pause & play)
I think you can get that opening the project with xcode & just run it
ok, now I will try wait please)
I just wanted to check have you fixed Notification on playlist mode in IOS before sleeping and unfortunately got this surprise )
on your code did you go here ?
} else {
print('something');
assetsAudioPlayer.open(Playlist(audios: audios), showNotification: true, autoStart: false);
}
Yes
I'll check, maybe an empty playlist crash :/
It printed something, also I tried not to start playlist and I showed me just list view and when I tapped it again crashed
can you add a print for your audios like
print("my audios = $audios");
to see if it's not empty
I printed its length and was correct also list view was not empty
but ok I will try
I'm currently trying to open an empty playlist on my sample
it does nothing, but no crash, it's another issue
ok, my program is still building 😅
what's in player/importPlayer.dart ?
import 'PlayerControl.dart'; import 'PlayerSpeed.dart'; import 'SongsSelector.dart'; import 'volumeSelector.dart'; import 'PositionSeekWidget.dart'; export 'PlayerControl.dart'; export 'PlayerSpeed.dart'; export 'SongsSelector.dart'; export 'volumeSelector.dart'; export 'PositionSeekWidget.dart'
AVAudioSession Notify Thread (32):
I'm trying to launch your project, I need the DezzerData please :)
import 'package:korshi/models/data.dart';
class DezzerData {
final List data; final int total;
DezzerData.fromJson(Map<String, dynamic> map):
data = List<Data>.from(map["data"].map((it) => Data.fromJsonMap(it))),
total = map["total"];
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['data'] = data != null ?
this.data.map((v) => v.toJson()).toList()
: null;
data['total'] = total;
return data;
}
}
import 'package:korshi/models/artist.dart'; import 'package:korshi/models/album.dart';
class Data { final int id; final String title; final String title_short; final String title_version; final String link; final int duration; final int rank; final bool explicit_lyrics; final int explicit_content_lyrics; final int explicit_content_cover; final String preview; final int position; final Artist artist; final Album album; final String type; Data.fromJsonMap(Map<String, dynamic> map): id = map["id"], title = map["title"], title_short = map["title_short"], title_version = map["title_version"], link = map["link"], duration = map["duration"], rank = map["rank"], explicit_lyrics = map["explicit_lyrics"], explicit_content_lyrics = map["explicit_content_lyrics"], explicit_content_cover = map["explicit_content_cover"], preview = map["preview"], position = map["position"], artist = Artist.fromJsonMap(map["artist"]), album = Album.fromJsonMap(map["album"]), type = map["type"];
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = id;
data['title'] = title;
data['title_short'] = title_short;
data['title_version'] = title_version;
data['link'] = link;
data['duration'] = duration;
data['rank'] = rank;
data['explicit_lyrics'] = explicit_lyrics;
data['explicit_content_lyrics'] = explicit_content_lyrics;
data['explicit_content_cover'] = explicit_content_cover;
data['preview'] = preview;
data['position'] = position;
data['artist'] = artist == null ? null : artist.toJson();
data['album'] = album == null ? null : album.toJson();
data['type'] = type;
return data;
}
}
class Artist {
final int id; final String name; final String link; final String picture; final String picture_small; final String picture_medium; final String picture_big; final String picture_xl; final bool radio; final String tracklist; final String type;
Artist.fromJsonMap(Map<String, dynamic> map):
id = map["id"],
name = map["name"],
link = map["link"],
picture = map["picture"],
picture_small = map["picture_small"],
picture_medium = map["picture_medium"],
picture_big = map["picture_big"],
picture_xl = map["picture_xl"],
radio = map["radio"],
tracklist = map["tracklist"],
type = map["type"];
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = id;
data['name'] = name;
data['link'] = link;
data['picture'] = picture;
data['picture_small'] = picture_small;
data['picture_medium'] = picture_medium;
data['picture_big'] = picture_big;
data['picture_xl'] = picture_xl;
data['radio'] = radio;
data['tracklist'] = tracklist;
data['type'] = type;
return data;
}
}
class Album { final int id; final String title; final String cover; final String cover_small; final String cover_medium; final String cover_big; final String cover_xl; final String tracklist; final String type;
Album.fromJsonMap(Map<String, dynamic> map):
id = map["id"],
title = map["title"],
cover = map["cover"],
cover_small = map["cover_small"],
cover_medium = map["cover_medium"],
cover_big = map["cover_big"],
cover_xl = map["cover_xl"],
tracklist = map["tracklist"],
type = map["type"];
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = id;
data['title'] = title;
data['cover'] = cover;
data['cover_small'] = cover_small;
data['cover_medium'] = cover_medium;
data['cover_big'] = cover_big;
data['cover_xl'] = cover_xl;
data['tracklist'] = tracklist;
data['type'] = type;
return data;
}
}
thanks :) I can try now
I have thread but it doesn’t show it with red sign it shows with purple
I'll send you the code, you have a lot of dynamic
in your code, I had to set the required type (like final audios = <Audio>[];
)
I think we don't have the same flutter version
what Is your flutter version and channel?
Flutter 1.19.0-2.0.pre.100 • channel master
the code works when I set types of variables
import 'dart:async';
import 'dart:convert';
import 'package:assets_audio_player/assets_audio_player.dart';
import 'package:assets_audio_player_example/player/PlaySpeedSelector.dart';
import 'package:assets_audio_player_example/player/PlayingControls.dart';
import 'package:assets_audio_player_example/player/VolumeSelector.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:provider/provider.dart';
import 'player/PositionSeekWidget.dart';
import 'player/SongsSelector.dart';
class Album {
final int id;
final String title;
final String cover;
final String cover_small;
final String cover_medium;
final String cover_big;
final String cover_xl;
final String tracklist;
final String type;
Album.fromJsonMap(Map<String, dynamic> map):
id = map["id"],
title = map["title"],
cover = map["cover"],
cover_small = map["cover_small"],
cover_medium = map["cover_medium"],
cover_big = map["cover_big"],
cover_xl = map["cover_xl"],
tracklist = map["tracklist"],
type = map["type"];
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = id;
data['title'] = title;
data['cover'] = cover;
data['cover_small'] = cover_small;
data['cover_medium'] = cover_medium;
data['cover_big'] = cover_big;
data['cover_xl'] = cover_xl;
data['tracklist'] = tracklist;
data['type'] = type;
return data;
}
}
class Data {
final int id;
final String title;
final String title_short;
final String title_version;
final String link;
final int duration;
final int rank;
final bool explicit_lyrics;
final int explicit_content_lyrics;
final int explicit_content_cover;
final String preview;
final int position;
final Artist artist;
final Album album;
final String type;
Data.fromJsonMap(Map<String, dynamic> map):
id = map["id"],
title = map["title"],
title_short = map["title_short"],
title_version = map["title_version"],
link = map["link"],
duration = map["duration"],
rank = map["rank"],
explicit_lyrics = map["explicit_lyrics"],
explicit_content_lyrics = map["explicit_content_lyrics"],
explicit_content_cover = map["explicit_content_cover"],
preview = map["preview"],
position = map["position"],
artist = Artist.fromJsonMap(map["artist"]),
album = Album.fromJsonMap(map["album"]),
type = map["type"];
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = id;
data['title'] = title;
data['title_short'] = title_short;
data['title_version'] = title_version;
data['link'] = link;
data['duration'] = duration;
data['rank'] = rank;
data['explicit_lyrics'] = explicit_lyrics;
data['explicit_content_lyrics'] = explicit_content_lyrics;
data['explicit_content_cover'] = explicit_content_cover;
data['preview'] = preview;
data['position'] = position;
data['artist'] = artist == null ? null : artist.toJson();
data['album'] = album == null ? null : album.toJson();
data['type'] = type;
return data;
}
}
class Artist {
final int id;
final String name;
final String link;
final String picture;
final String picture_small;
final String picture_medium;
final String picture_big;
final String picture_xl;
final bool radio;
final String tracklist;
final String type;
Artist.fromJsonMap(Map<String, dynamic> map):
id = map["id"],
name = map["name"],
link = map["link"],
picture = map["picture"],
picture_small = map["picture_small"],
picture_medium = map["picture_medium"],
picture_big = map["picture_big"],
picture_xl = map["picture_xl"],
radio = map["radio"],
tracklist = map["tracklist"],
type = map["type"];
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = id;
data['name'] = name;
data['link'] = link;
data['picture'] = picture;
data['picture_small'] = picture_small;
data['picture_medium'] = picture_medium;
data['picture_big'] = picture_big;
data['picture_xl'] = picture_xl;
data['radio'] = radio;
data['tracklist'] = tracklist;
data['type'] = type;
return data;
}
}
class DezzerData {
final List data;
final int total;
DezzerData.fromJson(Map<String, dynamic> map):
data = List<Data>.from(map["data"].map((it) => Data.fromJsonMap(it))),
total = map["total"];
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['data'] = data != null ?
this.data.map((v) => v.toJson()).toList()
: null;
data['total'] = total;
return data;
}
}
List musics = [];
int currentTrack = 0;
void main() => runApp(
MaterialApp(
home: MusicScreen()
)
);
class MusicScreen extends StatefulWidget {
static var id = 'sklfn;1';
@override
_MusicScreenState createState() => _MusicScreenState();
}
class _MusicScreenState extends State {
final assetsAudioPlayer = AssetsAudioPlayer();
final audios = <Audio>[];
List _subscriptions = [];
Future FututreData;
@override
void initState() {
print(assetsAudioPlayer.current.value.toString() + ' baaaan');
FututreData = fetchChuckyJoke();
_subscriptions.add(assetsAudioPlayer.playlistFinished.listen((data) {
// assetsAudioPlayer.open(Playlist(audios: audios,startIndex: 0),showNotification: true,autoStart: false);
}));
_subscriptions.add(assetsAudioPlayer.playlistAudioFinished.listen((data) {}));
_subscriptions.add(assetsAudioPlayer.current.listen((data) {}));
_subscriptions.add(assetsAudioPlayer.onReadyToPlay.listen((audio) {}));
super.initState();
}
Future<DezzerData> fetchChuckyJoke() async {
print('pizda');
try {
print('besiiiit');
final response = await http.get(('https://api.deezer.com/chart/0/tracks?limit=30&output=json'), headers: {
"Accept": "application/json",
"content-type": "application/json",
});
if (response.statusCode == 200) {
print('well done');
for (var i = 0; i < DezzerData.fromJson(json.decode(response.body)).data.length; i++) {
var c = DezzerData.fromJson(json.decode(response.body)).data[i];
audios.add(Audio.network(c.preview,
metas: Metas(
title: c.title,
artist: c.artist.name,
image: MetasImage.network(c.artist.picture_medium),
album: c.album.title,
)));
}
if (assetsAudioPlayer.current.value != null) {
} else {
print('something');
assetsAudioPlayer.open(Playlist(audios: audios), showNotification: true, autoStart: false);
}
// _assetsAudioPlayer.open(Playlist(audios: audios),showNotification: true,autoStart: false);
return DezzerData.fromJson(json.decode(response.body));
} else {
print('baaaaaan');
return null;
}
} catch (e) {
print(e);
}
}
Audio find(List source, String fromPath) {
return source.firstWhere((element) => element.path == fromPath);
}
@override
Widget build(BuildContext context) {
var height = 1000;
return Scaffold(
backgroundColor: Colors.black,
body: FutureBuilder(
future: FututreData,
initialData: null,
builder: (context, snapshot) {
return snapshot != null
? Padding(
padding: const EdgeInsets.only(bottom: 24.0),
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Stack(
fit: StackFit.passthrough,
children: <Widget>[
PlayerBuilder.current(
player: assetsAudioPlayer,
builder: (BuildContext context, Playing playing) {
if (playing != null) {
final myAudio = find(this.audios, playing.audio.assetAudioPath);
return Container(
height: height / 2.5,
child: Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(image: DecorationImage(image: NetworkImage(myAudio.metas.image.path), fit: BoxFit.cover)),
),
Container(
decoration: BoxDecoration(
gradient: LinearGradient(colors: [Colors.black.withOpacity(0.5), Colors.black], begin: Alignment.topCenter, end: Alignment.bottomCenter),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: Column(
children: <Widget>[
SizedBox(height: 52.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
GestureDetector(
child: Container(
decoration: BoxDecoration(color: Colors.white.withOpacity(0.1), borderRadius: BorderRadius.circular(50.0)),
child: Icon(
Icons.arrow_back_ios,
color: Colors.white,
),
),
onTap: () {
Navigator.pop(context);
},
),
Container(
child: Text(
' 😍TOP 30 песен с Dezzer 😍',
style: TextStyle(color: Colors.white, fontFamily: 'Mont'),
),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(50), color: Colors.black54),
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
)
],
),
Spacer(),
Text(myAudio.metas.title, textAlign: TextAlign.center, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 32.0)),
SizedBox(
height: 6.0,
),
Text(
myAudio.metas.artist,
style: TextStyle(color: Colors.white.withOpacity(0.6), fontSize: 18.0),
),
SizedBox(height: 16.0),
],
),
)
],
),
);
}
return SizedBox();
},
),
],
),
SizedBox(
height: 20,
),
PlayerBuilder.current(
player: assetsAudioPlayer,
builder: (context, playing) {
if (playing == null) {
return SizedBox();
}
return Column(
children: <Widget>[
PlayerBuilder.isLooping(
player: assetsAudioPlayer,
builder: (context, isLooping) {
return PlayerBuilder.isPlaying(
player: assetsAudioPlayer,
builder: (context, isPlaying) {
return PlayingControls(
isLooping: isLooping,
isPlaying: isPlaying,
isPlaylist: true,
toggleLoop: () {
assetsAudioPlayer.toggleLoop();
},
onPlay: () {
assetsAudioPlayer.playOrPause();
},
onNext: () {
//_assetsAudioPlayer.forward(Duration(seconds: 10));
assetsAudioPlayer.next();
},
onPrevious: () {
assetsAudioPlayer.previous();
},
);
});
},
),
PlayerBuilder.realtimePlayingInfos(
player: assetsAudioPlayer,
builder: (context, infos) {
if (infos == null) {
return SizedBox();
}
//print("infos: $infos");
return Column(
children: [
PositionSeekWidget(
currentPosition: infos.currentPosition,
duration: infos.duration,
seekTo: (to) {
assetsAudioPlayer.seek(to);
},
),
],
);
}),
],
);
}),
Expanded(
child: PlayerBuilder.current(
player: assetsAudioPlayer,
builder: (BuildContext context, Playing playing) {
return SongsSelector(
audios: audios,
onPlaylistSelected: (myAudios) {
assetsAudioPlayer.open(
Playlist(audios: myAudios),
showNotification: true,
);
},
onSelected: (myAudio) {
//error here assetsAudioPlayer.open(Playlist(audios: audios, startIndex: myAudio));
},
playing: playing,
);
}),
),
PlayerBuilder.volume(
player: assetsAudioPlayer,
builder: (context, volume) {
return VolumeSelector(
volume: volume,
onChange: (v) {
assetsAudioPlayer.setVolume(v);
},
);
}),
PlayerBuilder.playSpeed(
player: assetsAudioPlayer,
builder: (context, playSpeed) {
return PlaySpeedSelector(
playSpeed: playSpeed,
onChange: (v) {
assetsAudioPlayer.setPlaySpeed(v);
},
);
}),
],
),
)
: Center(
child: CircularProgressIndicator(backgroundColor: Colors.red, strokeWidth: 5),
);
}),
);
}
}
Channel dev, 1.19.0-1.0.pre
what I changed :
final audios = [];
--> final audios = <Audio>[];
Future fetchChuckyJoke() async {
--> Future<DezzerData> fetchChuckyJoke() async {
and the future provider
body: FutureBuilder(
future: FututreData,
initialData: null,
builder: (context, snapshot) {
can you try to run the code I sent to you ?
it have a main() inside, you just have to create a new main_test.dart
and run it in flutter flutter run -t lib/main_test.dart
Ok
Again this neurotrophic)
you forked my sample :)
It is building
And downloading macos tools 🧐
This is taking unexpectedly long time)
I'm still here don't worry
Ok)
App crashes and writes lost connection to device in IOS Real Device 13.3 IOS version. I tried put autoStart to false and play atIndex. Nothing has changed it still just crashes.