I tried something similar, my objective is to play all the songs without any further intervention, so I changed the name of the files using an incremental index.
The rule should be more or less the following (sorry I am a very beginner and the code is quite rough)
rule "musica disco on"
when
Item Play_switchlist changed from OFF to ON
then
var i=0
val result=executeCommandLine("wc -l /etc/openhab2/html/"+"adele"+".m3u", 5000) //this returns the number of files plus other information
var nameParts =result.split(" ")
var Parte=Double::parseDouble(nameParts.get(0))+1
while ((i=i+1) < Parte) {
var uri="http://192.xx.xx.xx:8080/static/adele1/adele_"
CCplayuri4.sendCommand (uri+i+".mp3")
Music4.sendCommand (PLAY)
}
end
The problem is that now each song start immediately after the previous one, stopping it, and I do not know how to delay the start of the new song (I do not know in advance the duration of the song). You suggest to exploit the state (in my example of Music4, I guess), but I do not know how to command to wait untill the state will change (strange is that a logInfo on Music4.state after the PLAY, returns PAUSE!?). Any idea?
I just upgraded to the latest snapshot build (2.2 - #1094). And I noticed that the ChromeCast binding received a big upgrade. From only 3 channels, it now has 30 channels. Someone has been busy. Thanks!
I didnāt do any tests yet. The documentation also isnāt updated yet. Iāll share my experienced when I have time.
If you decide to upgrade, donāt forget you must delete your CC Things and add them again in order to see the new channels.
@Bruno: there is also a channel ādurationā. Using that channel, you will know (I guess) when to play the next song.
2017-11-25 09:13:55.744 [WARN ] [g.discovery.internal.PersistentInbox] - Cannot create thing. No binding found that supports creating a thing of type chromecast:audio.
Since the upgrade to #1094 (and now still with #1103), I do get quite a lot of Chromecast errors in my log. Things like:
2017-12-01 22:37:26.059 [ERROR] [ome.core.thing.link.ThingLinkManager] - Exception occurred while informing handler: null
java.lang.NullPointerException: null
at su.litvak.chromecast.api.v2.ChromeCast.getRunningApp(ChromeCast.java:188) ~[?:?]
at su.litvak.chromecast.api.v2.ChromeCast.getMediaStatus(ChromeCast.java:291) ~[?:?]
at org.openhab.binding.chromecast.internal.ChromecastCommander.handleRefresh(ChromecastCommander.java:102) ~[?:?]
at org.openhab.binding.chromecast.internal.ChromecastCommander.handleCommand(ChromecastCommander.java:55) ~[?:?]
at org.openhab.binding.chromecast.handler.ChromecastHandler.handleCommand(ChromecastHandler.java:147) ~[?:?]
at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.channelLinked(BaseThingHandler.java:243) ~[?:?]
at org.eclipse.smarthome.core.thing.link.ThingLinkManager.lambda$0(ThingLinkManager.java:290) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
Or these:
2017-12-01 22:36:26.023 [WARN ] [su.litvak.chromecast.api.v2.Channel ] - Error while reading
su.litvak.chromecast.api.v2.ChromeCastException: Remote socket closed
at su.litvak.chromecast.api.v2.Channel.read(Channel.java:413) [219:org.openhab.binding.chromecast:2.2.0.201712011716]
at su.litvak.chromecast.api.v2.Channel.access$200(Channel.java:50) [219:org.openhab.binding.chromecast:2.2.0.201712011716]
at su.litvak.chromecast.api.v2.Channel$ReadThread.run(Channel.java:132) [219:org.openhab.binding.chromecast:2.2.0.201712011716]
2017-12-01 22:36:26.049 [WARN ] [su.litvak.chromecast.api.v2.Channel ] - <-- null payload in message
@Lewis I know this is an old thread but I was able to play a local mp3 file by placing the file in the [openhab2-dir]/conf/html directory and then calling it using the code below (of note, I used the default paperui config names).
rule ātest chromecastā
when
Item ChromecastTest changed from ON to OFF
then
CaveCast_PlayURI.sendCommand(āhttp://10.10.10.64:8080/static/barking.mp3ā)
CaveCast_Control.sendCommand(ON)
end
I hope this helps someone else. You can always place your mp3 on a public server as well, but I like having all my openhab config in one place for easy backups
I still havenāt figured out how to resume music playing after the announcement but I suppose this is an outstanding issue that everyone has.
I only just started using the binding a a day ago (and also just realised I am using an old version) but my plan was to store whatever is playing in a variable (ie url/ artist) and then feed it back to the chromecast after the announcement. Seems quite simple so Iām assuming it doesnāt work that easily if people are having issues?
@thejayo I also started using the binding yesterday but I am using the most recent snapshot from cloud bees. I know you can use the binding to retrieve song info, but Iām not sure there is a way with the current binding to save the currently playing url for playback after your announcement. If there is a way to do this that would be awesome.
Hi,
Has anyone gotten this to cast youtube videos?
I plan to set a schedule via rules to cast Youtube Sky News Live every 7AM on my TV.
The techslides sample works but I canāt get to cast youtube videos.
2018-03-20 20:21:38.863 [ome.event.ItemCommandEvent] - Item 'Play_Switch' received command ON
2018-03-20 20:21:38.993 [ome.event.ItemCommandEvent] - Item 'CastLRTV_URI' received command https://www.youtube.com/watch?v=XOacA3RYrXk
2018-03-20 20:21:39.084 [ome.event.ItemCommandEvent] - Item 'CastLRTV_Control' received command PLAY
How do you stream Google Play Music Playlist to chromecast? Do you use a rule or the native Google Play Music App on your Phone? I would like to start a Google Play Music Playlist. I have checked all items, but non of them offers me a clear URL or command of the Playlist.
So I finally got this to work. To play videos from youtube use the following. Replace XX with your Chromecast IP and change v=XXXXXX to the video you want
executeCommandLine('curl -H āContent-Type:application/jsonā "http://192.168.XX.XX:8008/apps/YouTube" -X POST -d "v=dQw4w9WgXcQ"', 5000)
Hi everyone, is there any ETA for Next/Previous buttons? Iām currently trying to control my Google Home players that are usually playing Spotify. Is there any workaround via API callback or something?