music_assistant 0.1.0 copy "music_assistant: ^0.1.0" to clipboard
music_assistant: ^0.1.0 copied to clipboard

Dart client for using working with the Music Assistant Websocket API from Dart and Flutter applications

example/main.dart

import 'dart:io';

import 'package:music_assistant/music_assistant.dart';

void main() async {
  // Create a client instance, pull url and token from env variables
  final client = MusicAssistantClient(
    serverUrl: Platform.environment['MA_SERVER_URL']!,
    token: Platform.environment['MA_TOKEN']!,
  );

  try {
    // Connect to the WebSocket server and authenticate
    await client.connect();

    // Fetch initial state for all endpoints (players, player queues, etc.)
    await client.fetchState();

    // Example: Print all players
    print('Players:');
    for (final player in client.players.all.values) {
      print('- ${player.name} (ID: ${player.playerId})');
    }
  } finally {
    // Disconnect from the server when done
    await client.disconnect();
  }
}
1
likes
160
points
8
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Dart client for using working with the Music Assistant Websocket API from Dart and Flutter applications

Repository (GitHub)
View/report issues
Contributing

License

MIT (license)

Dependencies

async, json_annotation, logging, uuid, web_socket_channel

More

Packages that depend on music_assistant