flutter_minimalist_audio_player 1.1.4 copy "flutter_minimalist_audio_player: ^1.1.4" to clipboard
flutter_minimalist_audio_player: ^1.1.4 copied to clipboard

This plugin is a simple UI implementation for AudioPlayer plugin. It simply display a icon button for playing media

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_minimalist_audio_player/flutter_minimalist_audio_player.dart';

const radios = {
  "Europe 2": "https://europe2.lmn.fm/europe2.mp3",
  "RTS": "https://sc.creacast.com/rts-national.mp3",
  "Skyrock": "https://icecast8.play.cz/skyrock128.mp3",
  "Europe 1": "https://europe1.lmn.fm/europe1.mp3"
};

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  MiniPlayer? _currentPlayer;

  @override
  void initState() {
    super.initState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('MinimalistAudioPlayer'),
        ),
        body: Center(
          child: ListView.builder(
            shrinkWrap: true,
            itemCount: radios.length,
            itemExtent: 50,
            itemBuilder: (context, index) {
              return DefaultTextStyle(
                  style: const TextStyle().copyWith(fontSize: 25, color: Colors.amber),
                  child: radioWidget(radios.keys.elementAt(index), radios.values.elementAt(index)));
            },
          ),
        ),
      ),
    );
  }

  Widget radioWidget(String name, String url) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Icon(
          Icons.radio,
          color: Theme.of(context).colorScheme.primary,
        ),
        const SizedBox(width: 5),
        Text(name),
        const SizedBox(width: 5),
        MinimalistAudioPlayer(
          media: url,
          beforeStart: (p) async {
            await _currentPlayer?.fadeOut();
            _currentPlayer = p;
          },
          onStop: (p) {
            if (_currentPlayer == p) _currentPlayer = null;
          },
        ),
      ],
    );
  }
}
2
likes
150
points
183
downloads

Publisher

unverified uploader

Weekly Downloads

This plugin is a simple UI implementation for AudioPlayer plugin. It simply display a icon button for playing media

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-2-Clause (license)

Dependencies

audioplayers, flutter

More

Packages that depend on flutter_minimalist_audio_player