kd_youtube_background_audio 0.0.6 copy "kd_youtube_background_audio: ^0.0.6" to clipboard
kd_youtube_background_audio: ^0.0.6 copied to clipboard

A robust Flutter package to reliably extract and play YouTube audio in the background. Handles muxed streams, Doze mode, and web CORS proxies.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:audio_service/audio_service.dart';
import 'package:kd_youtube_background_audio/kd_youtube_background_audio.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final audioHandler = await AudioService.init<KdYoutubeAudioHandler>(
    builder: () => KdYoutubeAudioHandler(),
    config: const AudioServiceConfig(
      androidNotificationChannelId: 'com.example.audio',
      androidNotificationChannelName: 'Audio playback',
    ),
  );

  runApp(MyApp(audioHandler: audioHandler));
}

class MyApp extends StatelessWidget {
  final KdYoutubeAudioHandler audioHandler;

  const MyApp({super.key, required this.audioHandler});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('KD YouTube Audio')),
        body: Center(
          child: ElevatedButton(
            onPressed: () async {
              await audioHandler.playFromYoutube(
                videoId: 'dQw4w9WgXcQ',
                useMuxed: true,
              );
            },
            child: const Text('Play Audio'),
          ),
        ),
      ),
    );
  }
}
1
likes
0
points
259
downloads

Publisher

verified publisherkhvichadev.com

Weekly Downloads

A robust Flutter package to reliably extract and play YouTube audio in the background. Handles muxed streams, Doze mode, and web CORS proxies.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

audio_service, flutter, http, just_audio, shared_preferences, youtube_explode_dart

More

Packages that depend on kd_youtube_background_audio