Finding media_content_id to cast to chromecast

Hi.

I want to be able to cast a specific Chromecast app. The problem is that I don’t know what data the app needs to cast specific content.

I know the app_id and the internal id of the content for this app, but trying to cast it does only result in the app opening, but no media playing.

  media_content_type: cast
  media_content_id: "{ \"app_id\": \"9C60F407\", \"media_id\": \"56d59c9f236b224052e6\" }"

I tried to inspect what might be sent when I cast from my PC with:

  1. mitmproxy with add root-CA. But I can’t see any HTTP(s) requests for the cast
  2. wireshark, but I can see no data that should contain some of the info I’m looking for.

I assume this is because the cast is encrypted but does not use HTTPs.

Has anyone successfully reverse-engineered what to send an arbitrary Chromecast app? In that case how?

What does Developer Tools > State say when you’re playing whatever content you want to be playing? Also look at the documentation for whatever integration your Chromecast is connected through I suppose. But submitting a media_content_id which in actuality contains a JSON-encoded string does not seem like the “Home Assistant way” to do things.

This is the state of a chromecast being casted to from the app I want to inspect.

volume_level: 0.25
is_volume_muted: false
media_content_id: 7cb870225f6d66534343
media_content_type: tvshow
media_duration: 17422.858
media_position: 65.778783
media_position_updated_at: 2025-01-22T19:40:16.805897+00:00
media_title: Nyhetsmorgon
app_id: 9C60F407
app_name: TV4 Play 3.0
entity_picture_local: /api/media_player_proxy/media_player.kitchen_display?token=3459c8e394a86375f5e15f8c04230106633970f204d85d72e96bf2512de5fc53&cache=bcabd97fef5b16e1
entity_picture: https://imageproxy.a2d.tv/?source=https://img.tv4.incomet.io/6f476f5f-2a6b-4693-bd78-31d995b024d8/crop16x9.jpg&width=1200
friendly_name: Kitchen display
supported_features: 152463

submitting a media_content_id which in actuality contains a JSON-encoded string does not seem like the “Home Assistant way” to do things.

This seems to be the way for doing what I want. Cast an app that is not Default Media Receiver: Google Cast - Home Assistant

Hmm. Then most likely the integration itself does nothing with the media id, just passes it along to the Chromecast, whose API expects a JSON encoded string.

Unless there is documentation somewhere for what the TV4 app expects as media_id I guess the only thing you can do it try everything? Have you tried using the entire URL as if you would link directly on the episode on their website? I.e.

https://www.tv4play.se/video/4e401656edcff82b17dc/avsnitt-1-ett-mystiskt-tips

(Also for future reference, to avoid silly escaping mistakes it would be safer to not write the JSON manually but assemble a YAML/Jinja dict and pass to the to_json filter.)