on_audio_room 2.0.0-beta.0 copy "on_audio_room: ^2.0.0-beta.0" to clipboard
on_audio_room: ^2.0.0-beta.0 copied to clipboard

outdated

Flutter Package used to create a room to storage audio sections [Favorites, Internal Playlists, Most Played, etc...].

example/lib/main.dart

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

void main() async {
  //Init Room.
  await OnAudioRoom().initRoom(RoomType.PLAYLIST);
  runApp(MaterialApp(home: MyApp()));
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  //Call audio room.
  OnAudioRoom audioRoom = OnAudioRoom();

  @override
  void dispose() {
    //Remember to close room to avoid memory leaks.
    //Choose the better location(page) to add this method.
    audioRoom.closeRoom();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("OnAudioRoomExample"),
        actions: [
          IconButton(
            onPressed: () async {
              var result = await audioRoom.createPlaylist("entity");
              setState(() {
                print(result);
              });
            },
            icon: Icon(Icons.add),
          ),
          IconButton(
            onPressed: () async {
              var result = await audioRoom.clearPlaylists();
              setState(() {
                print(result);
              });
            },
            icon: Icon(Icons.delete_forever_outlined),
          ),
        ],
      ),
      body: FutureBuilder<List<PlaylistEntity>>(
        future: OnAudioRoom().queryPlaylists(),
        builder: (context, item) {
          if (item.data != null) {
            List<PlaylistEntity> songs = item.data!;
            return ListView.builder(
              itemCount: songs.length,
              itemBuilder: (context, index) {
                return ListTile(
                  title: Text(songs[index].playlistName),
                  subtitle: Text(DateTime.fromMillisecondsSinceEpoch(
                          songs[index].playlistDataAdded!)
                      .toString()),
                  onTap: () async {
                    var result = await audioRoom.renamePlaylist(
                        songs[index].key, "newName");
                    setState(() {
                      print(result);
                    });
                  },
                );
              },
            );
          }
          return Center(child: CircularProgressIndicator());
        },
      ),
    );
  }
}
14
likes
0
pub points
58%
popularity

Publisher

verified publisherlucasjosino.com

Flutter Package used to create a room to storage audio sections [Favorites, Internal Playlists, Most Played, etc...].

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, hive, hive_flutter, nanoid, path_provider

More

Packages that depend on on_audio_room