sendorm
(Sendorm)
July 30, 2017, 7:12am
1
Hello, this is a very basic question but I couldn’t seem to get it working.
I have a local file at www folder named “test.mp3” and trying to play this file from a media player, I used vlc and mpc.
action:
service: media_player.play_media
data:
entity_id: media_player.testsound
media_content_id: '/local/test.mp3'
media_content_type: 'audio/mp3'
I’ve also tried:
action:
service: media_player.play_media
data:
entity_id: media_player.testsound
media_content_id: '/local/test.mp3'
media_content_type: 'music'
I also tried the service with this code:
{ "data": {"media_content_id":"/local/test.mp3","media_content_type":"audio/mp3"} }
I keep getting the error:
ERROR (MainThread) [homeassistant.core] Invalid service data for media_player.play_media: extra keys not allowed @ data['data']. Got {'media_content_id': '/local/test.mp3', 'media_content_type': 'music'}
required key not provided @ data['media_content_id']. Got None
required key not provided @ data['media_content_type']. Got None
Thank you
1 Like
Gilganik
(Nik)
September 17, 2017, 7:08pm
2
Hi,
You need to specify in the “media_Content_id” the full path of the audio file.
Something like: /home/pi/homeassistant/www/songs/test.mp3
Have a good day
Nik
Bob_NL
(Bob Visser)
September 17, 2017, 7:56pm
3
Your syntax looks fine to me, the “/local/test.mp3” path should also not give any problems.
Can you try an online file to see if it works?
service: media_player.play_media
data:
entity_id: media_player.home_group
media_content_id: https://dl.dropboxusercontent.com/s/cv0u9tsp327n3u7/T99.mp3?dl=0
media_content_type: 'audio/mp3'
2 Likes
sendorm
(Sendorm)
September 18, 2017, 3:09pm
4
Hello,
The fix included:
media_player:
- platform: vlc
name: testsound
arguments: '--alsa-audio-device=hw:0,0'
This sets the output to audio jack and not the hdmi. Which fixed the actual problem.
Both your examples are correct by the way. @Gilganik yeah setting "/local/test.mp3"
does not work, as you said "/home/pi/.homeassistant/www/test.mp3"
has to be used.
but @Bob_NL you have to use media_content_type: 'music'
otherwise it won’t work.
Thanks everyone.
2 Likes
Bob_NL
(Bob Visser)
September 18, 2017, 4:59pm
5
media_content_type: ‘audio/mp3’ and ‘audio/mp4’ both working fine here.
sendorm
(Sendorm)
September 18, 2017, 5:36pm
6
Bob_NL:
audio/mp3
Try this in services:
{ "entity_id" : "media_player.xxxxx", "media_content_id": "https://dl.dropboxusercontent.com/s/cv0u9tsp327n3u7/T99.mp3?dl=0", "media_content_type":"audio/mp3"}
mine gives error:
[homeassistant.components.media_player.vlc] Invalid media type audio/mp3. Only music is supported
My media player is vlc and I am on HA version 0.53.1 by the way.
Bob_NL
(Bob Visser)
September 18, 2017, 7:43pm
7
sendorm:
mine gives error:
Perhaps it has something to do with VLC, I’m using Chromecasts.
Edit: jep that’s it:
https://home-assistant.io/components/media_player.vlc/
Only the “music” media type is supported for now.
sendorm
(Sendorm)
September 18, 2017, 7:46pm
8
Thank you for the clarification.
RobDYI
February 12, 2018, 6:18pm
9
Not sure what music type does but this works.
- service: media_player.play_media
data:
entity_id: media_player.speaker
media_content_id: /home/pi/Downloads/play.mp3
media_content_type: 'music'
2 Likes
Anybody any idea what would be the media_content_id of a Google Play music playlist or the “I feel lucky” functionality? Or isn’t that possible because of the authentication?
1 Like
Egglec
(James Eggleston)
July 29, 2019, 12:47pm
11
For the aid of others reading this post later. I have had I problem with getting media_player.play_media to work. And I finally figured out that the media file name is case sensitive. So what you have here in the second example works:
media_content_type: 'music'
but ensure the file path is correct including the Case.
zejulio
(Julio Silva)
February 28, 2020, 12:14am
12
How do I install VLC on HassOs?
I want to play tts locally, its on a PC with VMWare, and i would like to play tts in the speakers, is it possible?
Thanks!
macnug
May 15, 2020, 8:28am
13
Egglec:
ame is case sensitiv
Hi, i tries everything like you but i didn’t figure out the issue.
my script in scripts.yaml is
perdita_acqua_cucina:
alias: perdita acqua cucina notifica vocale
sequence:
- service: media_player.play_media
data:
entity_id: media_player.google_home_mini_sala
media_content_id: https://192.168.0.14:8123/local/config/www/Audio/Siren.mp3 #sftp://[email protected] /config/www/Audio/Siren.mp3 this is the path of the mp3 from #filezilla
media_content_type: 'music'
Really i tried everything, can you give me some advice?
Thanks
maxkrok
(Max Krok)
July 9, 2020, 10:59am
14
The correct way is:
media_content_id: local:track:misc/xxx.mp3
media_content_type: music
Where “misc/” is a subdirectory inside
media_dir = /share/mopidy/media
1 Like
myT
January 10, 2021, 8:33pm
15
If locally downloaded and stored in externally accessible folder, eg: www/media/PoliceSireneYT=Jr0HpAENhTM.mp4:
service: media_player.play_media
data:
media_content_id: /local/media/PoliceSireneYT=Jr0HpAENhTM.mp4
media_content_type: video
entity_id: media_player.hub
when using from youtube directly using Media Extractor (seems even faster to cast),
service: media_extractor.play_media
data:
entity_id: media_player.hub
media_content_id: 'https://www.youtube.com/watch?v=Jr0HpAENhTM'
media_content_type: video/youtube
Viking
January 14, 2021, 7:40pm
16
Hi All, What’s wrong with this:
type: button
tap_action:
action:
service: media_player.play_media
data:
entity_id: media_player.stue_ac
media_content_id: https://p7.p4groupaudio.com/P07_MH
media_content_type: music
entity: media_player.stue_ac
If I use the service tab under developer tools, and enter the exact same, it works just fine.
I am so frustrated. Please help.
Its not data
but service data
try this
type: button
tap_action:
action:
service: media_player.play_media
service_data:
entity_id: media_player.stue_ac
media_content_id: https://p7.p4groupaudio.com/P07_MH
media_content_type: music
entity: media_player.stue_ac
Viking
January 15, 2021, 5:51am
18
Thank you.
But in addition, I also had to add:
action: call-service
So, now it finally works
Nitroedge
(Brandon)
September 8, 2024, 3:16pm
19
You said you added this to make it work.
Where did you add the “action: call-service” line in your code?
type: button
tap_action:
action:
service: media_player.play_media
service_data:
entity_id: media_player.stue_ac
media_content_id: https://p7.p4groupaudio.com/P07_MH
media_content_type: music
entity: media_player.stue_ac
Viking
September 8, 2024, 8:11pm
20
I’ve made several changes since I last visited this thread, so now the code looks like this:
show_name: true
name: P7 Klem
type: button
tap_action:
action: call-service
service: media_player.play_media
metadata:
title: Klem FM
thumbnail: >-
https://ddjh0q34m0xak.cloudfront.net/mmo/channelimages/dab99854-1427-4d94-a01d-693a75bc9b26.png?h=200
media_class: music
children_media_class: null
navigateIds:
- {}
- media_content_type: app
media_content_id: media-source://radio_browser
- media_content_type: music
media_content_id: media-source://radio_browser/country/NO
data:
media_content_id: media-source://radio_browser/6f4fe23b-25c3-4401-a01e-15bce5da1352
media_content_type: audio/mpeg
target:
entity_id: media_player.ema_speaker
entity: media_player.ema_speaker