Announcement

Collapse
No announcement yet.

Changing Internet Radio Stations

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Changing Internet Radio Stations

    Hi all,

    Does anyone know of a simple way that I can use an event to cycle through a list of streaming radio stations? I have created a few playlists in WMP that work just fine but have no idea what to do within an event to "change stations". I have also tried to create a playlist with multiple station URLs and then execute a change track command and that did not do the trick.

    Any thoughts? I am ultimately trying to use an event that monitors a change in value on a zwave device for this purpose - kind of a poor-man's remote control.

    Thanks!

    #2
    Do you want an event that goes to the next playlist? Not sure you can do that, rather just play a specific playlist. You would need an event per radio station if i'm right.

    What I do is I have an ini file that contains the name of the station and the URL, I have a page of buttons in HSTouch that have different labels on and each have a numeric value, when I press a button it passes that numeric value to a script - then pulls the URL and title corresponding to that value and plays it, thats rather than having 15 playlists I have one ini file and one vb script.

    Comment


      #3
      if you control it through a keyboard, you could use HS.Keys....

      Comment


        #4
        Originally posted by mrhappy View Post
        Do you want an event that goes to the next playlist? Not sure you can do that, rather just play a specific playlist. You would need an event per radio station if i'm right.

        What I do is I have an ini file that contains the name of the station and the URL, I have a page of buttons in HSTouch that have different labels on and each have a numeric value, when I press a button it passes that numeric value to a script - then pulls the URL and title corresponding to that value and plays it, thats rather than having 15 playlists I have one ini file and one vb script.
        Could you please help me do the same?
        I try playing a radio station within media player plugin but i dont know about scripting.
        I know to use well the hstouch interface, can make buttons respond to commands, but how do you call a script in hstouch?
        secondly where do you put this script, how do you write it (using notepad?)
        And finally about that ini file you say, what is its name and where you save it?

        Maybe you could you send me your code in the ini file as soon as the script you wrote for help.

        Thanks in advance, Gas

        Comment


          #5
          Can you post it here, Mr. Happy? I'd like to do the same.
          Mark

          Comment


            #6
            Sure thing, the script can be written in notepad - just copy the below code into notepad and save it with a .vb file extension, then save it in your HomeSeer\Scripts directory.

            To call a script from HSTouch, go into the actions editor and you should find 'Run A HomeSeer script with values from elements', then in that line write;

            &hs.runex("radio.vb", "Main", "1")

            Now '1' represents which radio station to play, it pulls that from a list in an ini file, you will also need to copy the below ini file code into notepad and save it as a .ini file in your HomeSeer\Config directory.

            Here is the .vb code, save it as radio.vb;

            PHP Code:
            Sub Main(ByVal Data As Object

            Dim pi As Object 
            Dim parms 
            as Object
            Dim MusicApi 
            As object 
            Dim URL 
            as String
            Dim title 
            as String

            pi 
            hs.Plugin("Media Player"

            pi.MusicApi.StopPlay

            URL 
            hs.getinisetting("Data"Data(0), """radio.ini")

            title hs.getinisetting("Title"Data(0), """radio.ini")

            hs.speak(title)

            pi.MusicApi.PlayMusic("","","","","",URL)

            hs.writelog("Radio"title)

            End Sub 
            This is radio.ini;

            PHP Code:
            [Data]
            1="http://www.bbc.co.uk/radio/listen/live/r1.asx"
            2="http://www.bbc.co.uk/radio/listen/live/r2.asx"
            3="http://bbc.co.uk/radio/listen/live/r6.asx"
            4="http://mediasrv-sov.musicradio.com/GalaxyBirmingham"
            5="http://media-ice.musicradio.com/ChillMP3.m3u"
            6="http://media-ice.musicradio.com/XFMMP3.m3u"
            7="http://url/url"
            8="http://url/url"
            [Title]
            1="BBC Radio One"
            2="BBC Radio Two"
            3="BBC Six Music"
            4="Galaxy FM Birmingham"
            5="Chill Music"
            6="XFM"
            7="URL7"
            8="URL8" 
            There is no limit to how many stations you want to add, the title entries are spoken via the speaker client, if you do not want to do this then delete the lines starting title = and hs.speak

            Comment


              #7
              Thank you very much! You were very helpfull! Till now, i used to listen to web sites radio stations...! Now i can make mine!!!

              Comment


                #8
                Well, I have an easy problem...
                Easy for you, I mean!
                When I add more than 9 stations, then your script cannot read the right number, it always reads number 10 untill number 19 as number 1 !!!
                and reads numbers from 20-29 as number 2 !
                I think you understand the problem, the bug is in the

                { title = hs.getinisetting("Title", Data(0), "", "radio.ini") }
                and
                { URL = hs.getinisetting("Data", Data(0), "", "radio.ini") }

                because it does not load the right station not even speaking the right number of station, and the log file in homeseer writes as station nubmber 1...(or 2)

                I see that i have to write something else in data(0). I tried to write data(00) but no luck...
                I even tried to write the numbers in radio.ini as 01,02,03,...10,11,12... I mean with zeros before numbers, but no luck at all!
                Can you help?
                Thanks in advance, Gas

                Comment


                  #9
                  The purpose of the numbers to the left of the "=" is simply a unique key. Conceptually I do not see a reason HS cannot distinguish 1 from 10, but if you use alphanumeric rather than numerics then the problem may disappear. For example use "A1", "A2", "A10" rather than 1,2 and 10. This would be in both sections of the .ini file and in the value passed into the script. Worth a try.

                  Comment


                    #10
                    I did try, but no luck...
                    I made keys like a1,a2...a9 and keys b1,b2...b9 but the HS log file sees nothing... {says speak(): it means it does not see any of the .ini keys} it works only with keys 1 till 9. nothing else.
                    I think it has to do with the syntax of the getinisettings command. Does anyone know about the syntax of this command? I dont even know how to google it...
                    P.S. What the DATA(0) means?

                    Comment


                      #11
                      Sorry that was my fault for not checking, please try this;

                      PHP Code:
                      Sub Main(ByVal Data As Object

                      Dim pi As Object 
                      Dim parms 
                      as Object
                      Dim MusicApi 
                      As object 
                      Dim URL 
                      as String hs.getinisetting("Data"CStr(Data), """radio.ini")
                      Dim title as String hs.getinisetting("Title"CStr(Data), """radio.ini")

                      If 
                      URL "" Then

                      hs
                      .writelog("Radio""No station in INI file matching this key")

                      Else

                      pi hs.Plugin("Media Player"

                      pi.MusicApi.StopPlay

                      hs
                      .speak(title)

                      pi.MusicApi.PlayMusic("","","","","",URL)

                      hs.writelog("Radio"title)

                      End If

                      End Sub 
                      I got confused (and i've never used more than 8 entries myself) and thought the parameters from HSTouch were seperated per parameter however it seems to be per character, so in the case of sending the parameter 10 Data(0) holds the number 1 and Data(1) would hold the number 0. Data(x) is an array and there is another method of reading through the array with the UBound syntax.

                      Hopefully now it should work as Data is converted to a string straight away, and it will tell you if you are trying to call a station that does not exist.

                      Comment


                        #12
                        Thank you very much again!
                        Its OK now.
                        I see people trying to debug in php saying that they read about the syntax of something in the "help" file... where is that help file that writes about the format of the php? i think that learning languages has nothing to do with homeseer.
                        thanks for your help one more time

                        Comment


                          #13
                          Originally posted by coolgas View Post
                          Thank you very much again!
                          Its OK now.
                          I see people trying to debug in php saying that they read about the syntax of something in the "help" file... where is that help file that writes about the format of the php? i think that learning languages has nothing to do with homeseer.
                          thanks for your help one more time
                          The help file is here http://www.homeseer.com/support/home...2/homeseer.htm (its also included on your HS PC somewhere) and on the left hand side you should have 'Using Scripts', there you will find a few helpful tips and from there Scripting Functions shows you all of the scripting functions that HS adds.

                          Some more specialist scripting commands for the WMP plugin and HSTouch are located in the help file for the plugins themselves.

                          I think the two most popular languages are VB.NET and VBScript, whilst you can use HomeSeer without scripts but to access and do some more advanced things you will end up using them.

                          Comment

                          Working...
                          X