Skip to content

Feature Request: Google Cast Support via SharpCaster #39

Open

Description

@oca-agent

I would like to propose adding support for browsing and controlling Google Cast devices within smoc. This would allow users to cast their music to speakers, TVs, and other Cast-enabled devices directly from the CLI.

High-Level Plan

  1. Device Discovery: Integrate SharpCaster to discover devices on the local network.
  2. Audio Service Implementation: Create a new IAudioService implementation (CastAudioService) that targets a selected Cast device.
  3. Playback Service Implementation: Create a CastPlaybackService that implements IPlaybackService to control remote playback.
  4. Local Stream Proxy: Since smoc handles audio as Stream objects, implement a lightweight HTTP proxy to serve these streams to the Cast device.
  5. UI Integration: Implement a command (e.g., :output) to list and select output devices via the command line interface.

Detailed Implementation Plan

1. Core Services

  • ICastDiscoveryService:
    • Task<IEnumerable<Chromecast>> DiscoverDevicesAsync()
    • Uses SharpCaster.DeviceFinder.
  • CastPlaybackService (implements IPlaybackService):
    • Wraps SharpCaster.ChromecastClient and its MediaStatus.
    • Bridges MediaStatus updates to PositionChanged and PlaybackStateChanged events.
    • Implements Play(), Pause(), Stop(), and Seek() by calling the respective SharpCaster methods.
  • CastAudioService (implements IAudioService):
    • Acts as the factory for CastPlaybackService.
    • Manages the connection to the specific Chromecast device.
    • Manages the lifecycle of a local HttpListener to proxy the Stream from IStreamingClient to the Chromecast's required URL.

2. Streaming Proxy

  • A StreamProxyService that:
    • Listens on a random local port.
    • Generates a transient URL (e.g., http://<local-ip>:<port>/stream/<guid>).
    • When the URL is requested, it pipes the Stream from IStreamingClient to the HTTP response.
    • This ensures that any smoc supported stream (Subsonic, etc.) can be played on the Cast device even if the device doesn't have direct access to the source.

3. UI/UX Changes

  • Implement a new command :output in the command bar.
  • Running :output without arguments lists available devices (Local, discovered Cast devices).
  • Running :output <name> (with auto-completion support) switches the active output device.
  • Display the current output device in the status bar or playback info area.
  • Update StandardPlaybackQueueService to switch the underlying IAudioService implementation when a new device is selected via the command.

Dependencies

  • SharpCaster (NuGet) - Latest version (3.0.0)

Activity

  1. mrazza commented on May 15, 2026

    @mrazza
    Owner

    Give this a shot. Let's see what it looks like and how it works.

  2. oca-agent commented on May 24, 2026

    @oca-agent
    CollaboratorAuthor

    Google Cast support has been fully implemented and submitted in PR #40 (#40). It includes device discovery via SharpCaster, dynamic playback/audio service switching, a local HTTP streaming proxy, and the UI command with tab completion. All reviews have been addressed and local tests pass successfully. Please review!

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions