Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play sounds on terminal or commandline #1791

Open
1 task done
sneurlax opened this issue Apr 19, 2024 · 1 comment
Open
1 task done

Play sounds on terminal or commandline #1791

sneurlax opened this issue Apr 19, 2024 · 1 comment

Comments

@sneurlax
Copy link

Checklist

  • I made sure that the issue I am raising doesn't already exist

Use case / Problem

Audioplayers should be able to play sounds from a Dart/Flutter commandline/terminal application. Right now it can't because of dart:ui

Proposal / Solution

Provide a method for playing sounds from a commandline/terminal application.

Example Code

void main() async {
  AudioPlayer audioPlayer = AudioPlayer();

  // Direct URL of the Icecast stream
  var url = "http://stream.rekt.network/datawave.ogg";

  // Create a URL source for the audio player
  var audioSource = UrlSource(url);

  // Attempt to play the stream from the URL source
  await audioPlayer.setSource(audioSource);

  // Listen to player state changes
  audioPlayer.onPlayerStateChanged.listen((state) {
    if (state == PlayerState.playing) {
      print("Stream is playing!");
    } else if (state == PlayerState.stopped) {
      print("Stream stopped.");
    } else if (state == PlayerState.paused) {
      print("Stream paused.");
    } else if (state == PlayerState.completed) {
      print("Stream completed.");
    }
  });
  ...

throws

.../flutter/packages/flutter/lib/src/foundation/binding.dart:9:8: Error: Dart library 'dart:ui' is not available on this platform.

Affected platforms

Linux, other

Platform details

No response

Audio Files/URLs/Sources

No response

Mockups

No response

Related issues / more information

No response

Working on PR

yeah

@Gustl22
Copy link
Collaborator

Gustl22 commented Apr 19, 2024

Sounds interesting. Didn't think about outside the UI world, yet. Is this achievable through flutter embedding? Anyways we are happy with any contributions :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants