'Flutter : audio_service with Video player
how can i use audio_service
package with video player(ex : chewie
or pod_player
) to play video in background and Android lock screen and notification, iOS control center
my main :
late AudioHandler _audioHandler;
void main() async {
WidgetsFlutterBinding.ensureInitialized();
_audioHandler = await AudioService.init(
builder: () => MyAudioHandler(),
config: AudioServiceConfig(
androidNotificationChannelId: 'com.app.myapp.channel.audio',
androidNotificationChannelName: 'Music playback',
androidNotificationOngoing: true,
),
);
runApp(const MyApp());
}
my player class :
class YoutubePlayer extends StatefulWidget {
final String url;
const YoutubePlayer({Key? key, required this.url}) : super(key: key);
@override
State<YoutubePlayer> createState() => _YoutubePlayerState();
}
class _YoutubePlayerState extends State<YoutubePlayer> {
late final PodPlayerController controller;
@override
void initState() {
controller = PodPlayerController(
playVideoFrom: PlayVideoFrom.youtube(widget.url,),
podPlayerConfig: const PodPlayerConfig(initialVideoQuality: 360),
)..initialise();
super.initState();
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: PodVideoPlayer(controller: controller),
);
}
all result in google with just_audio i not found with video
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|