Announcement

Collapse
No announcement yet.

Scripting Function List

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

    Scripting Function List

    Scripting functions are all grouped as methods under the "scripting" property. For example to play a song, you could use something like this:

    Set hspiWMP = hs.GetPlugins("Media Player").scripting
    hspiWMP.play "Album", "Greatest Hits", "The best song"

    "CategoryType" is either "Album", "Artist", "Genre", "Playlist", or "Media Library". For "Media Library", "Category Name" is ignored.

    Scripting Function List:
    <UL TYPE=SQUARE><LI>Function Play(CategoryType As String, CategoryName As String, Optional Title As String = "") As Long
    <LI>Function PlayURL(URL As String) As Long
    <LI>Sub PausePlayer()
    <LI>Sub ResumePlayer()
    <LI>Sub StopPlayer()
    <LI>Property Mute() As Boolean
    msgbox "Player is muted: " & hspiWMP.Mute
    <LI>Property Let Mute(State)
    hspiWMP.Mute = true
    hspiWMP.Mute = "toggle"
    <LI>Property Get LoopMode()
    msgbox "Loop Mode is: " & hspiWMP.LoopMode
    <LI>Property Let LoopMode(State)
    hspiWMP.LoopMode = true
    hspiWMP.LoopMode = "toggle"
    <LI>Property Get ShuffleMode()
    msgbox "Shuffle Mode is: " & hspiWMP.ShuffleMode
    <LI>Property Let ShuffleMode(State)
    hspiWMP.ShuffleMode = true
    hspiWMP.ShuffleMode = "toggle"
    <LI>Sub PlayNext()
    <LI>Sub PlayPrev()
    <LI>Sub Restart()
    <LI>Sub FastForward()
    <LI>Sub FastReverse()
    <LI>Sub Eject(Optional Drive As Integer = 0)
    <LI>Sub VolumeUp(Optional Percent As Integer = 10)
    <LI>Sub VolumeDown(Optional Percent As Integer = 10)
    <LI>Property Let Volume(Percent As Integer)
    hspiWMP.Volume = 50
    <LI>Property Get Volume() As Integer
    msgbox "Volume is: " & hspiWMP.Volume
    <LI>Function GetCategoryList(CatType As String) As Collection
    <LI>Function GetByCategory(Optional CatType As String = "Media Library", Optional CategoryName As String = "") As Collection
    <LI>Property Get PlayerStatus() As String
    <LI>Property Get Title() As String
    <LI>Property Get Artist() As String
    <LI>Property Get Album() As String
    <LI>Property Get Genre() As String
    <LI>Property Get Length() As String
    <LI>Property Get ShowPopupControls()
    msgbox "Pop-up controls are displayed: " & hspiWMP.ShowPopupControls
    <LI>Property Let ShowPopupControls(State)
    hspiWMP.ShowPopupControls = true
    hspiWMP.ShowPopupControls = "toggle"
    <LI>Property Let FullScreenVideo(State)
    hspiWMP.FullScreenVideo = true
    hspiWMP.FullScreenVideo = "toggle"
    <LI>Function AddToPlayList(Optional Reserved1 As String, Optional Reserved2 As String, Optional Reserved3 As String = "", Optional sPlayListName As String = "HomeSeer")
    Adds currently playing song to the playlist.
    <LI>Function CurrentPlaylist()
    msgbox "The current playlist is: " & hspiWMP.CurrentPlaylist
    <LI>Function GetMediaInfo(CategoryType As String, CategoryName As String, Title As String) As Collection
    Set hspiMediaInfo = hspiWMP.GetMediaInfo("Artist", "Janet", "Best Song")
    MsgBox "Album=" & hspiMediaInfo("Album") & vbCrLf _
    & "Artist=" & hspiMediaInfo("Artist") & vbCrLf _
    & "Genre=" & hspiMediaInfo("Genre") & vbCrLf _
    & "Duration=" & hspiMediaInfo("Duration")

    <LI>Function GetAlbumsByCategory(CategoryType As String, CategoryName As String) As Collection
    <LI>Sub RefreshLists(CategoryType As String)
    hspiWMP.RefreshLists "Artist"
    <LI>Property Get WMPObject() As Object
    Full access to the WMP object. This object is available as a convenience to extremely advanced developers only. Because of its complexity, technical support for this object is not available. More information about the object can be found at WMP9 SDK[/list]

    note: GetAlbumsByCategory requires version 1.0.17 or above
    -Geoff

    #2
    Hey Everyone,
    FYI: I dont think this applies to the latest Media Player plugins. (2.4.x)

    Regards, Bill


    ~Bill

    Comment


      #3
      Media Player scripting

      Originally posted by Bill Brower View Post
      Hey Everyone,
      FYI: I dont think this applies to the latest Media Player plugins. (2.4.x)

      Regards, Bill

      Bill,

      I'm inclined to agree. At some point in the last 8 weeks or so, my scripts that handle media player stopped working... particularly my volume control script... and now a script that's suppossed to play a .wav file.

      That second one is erroring on a line that says:

      Set hspiWMP=hs.GetPlugins("Media Player").scripting

      Error message I'm getting is:
      12/4/2008 4:45:52 PM - Error - Running script, script run or compile error in file: playsoundfile.txt424:Object required: 'hs.GetPlugins(...)' in line 7 More info: Object required: 'hs.GetPlugins(...)'


      Does anybody know a fix?


      -= Dave =-

      Comment


        #4
        Hmmm.... things have changed

        Just found what appear to be the updated docs at http://localhost/mediaplayer/help/help.htm

        Haven't tried this yet, but things definitely look different:

        "Scripting the Media Player Plugin
        The Media Player plug-in uses a new Music API scripting interface for script commands. To issue commands or get information via the MusicAPI, you must first access the plug-in via HomeSeer:

        Dim pi As Object
        pi = hs.Plugin("Media Player")

        Dim MusicApi As HSPI_MEDIAPLAYER.HSMusicAPI
        MusicApi = pi.GetMusicAPI(1)

        Now you may reference MusicAPI commands through this reference....

        MusicAPI.Play"


        -= Dave =-

        Comment


          #5
          Tried this URL. nothing there. My version is 2.2.0.66. Is there some way to navigate to this help file?


          Originally posted by DR4296 View Post
          Just found what appear to be the updated docs at http://localhost/mediaplayer/help/help.htm

          Haven't tried this yet, but things definitely look different:

          "Scripting the Media Player Plugin
          The Media Player plug-in uses a new Music API scripting interface for script commands. To issue commands or get information via the MusicAPI, you must first access the plug-in via HomeSeer:

          Dim pi As Object
          pi = hs.Plugin("Media Player")

          Dim MusicApi As HSPI_MEDIAPLAYER.HSMusicAPI
          MusicApi = pi.GetMusicAPI(1)

          Now you may reference MusicAPI commands through this reference....

          MusicAPI.Play"


          -= Dave =-
          Don

          Comment


            #6
            localhost

            Hopefully, you realize that that URL refers to a location on YOUR Homeseer-installed PC ? (It is NOT some site out on the Internet.)

            Just thought I'd clarify that, in case somebody out there isn't familiar with what "localhost" refers to.

            -= Dave =-

            Comment


              #7
              Understood :-)
              Originally posted by DR4296 View Post
              Hopefully, you realize that that URL refers to a location on YOUR Homeseer-installed PC ? (It is NOT some site out on the Internet.)

              Just thought I'd clarify that, in case somebody out there isn't familiar with what "localhost" refers to.

              -= Dave =-
              Don

              Comment


                #8
                Well, red face here...I didn't realize that I was quite a few iterations down of the WMP Plugin. I upgraded and discovered my scripts no longer function

                Following Geoff's instructions for scripting I am now getting an 'Script error: Object required: hs.GetPlugins(...)'
                The offending line of code is

                PHP Code:
                Set hspiWMP.GetPlugins("Media Player").scripting 
                Can anyone see a problem? I have tried this as an asp and vbs script.

                thanks
                Last edited by donstephens; January 29, 2009, 05:41 PM.
                Don

                Comment


                  #9
                  The newest Media Player plugin is a .net plugin and requires a vb.net script like the following:

                  Sub Main(parm as object)
                  Dim pi As Object
                  pi = hs.Plugin("Media Player")
                  Dim MusicApi As object
                  MusicApi = pi.GetMusicAPI(1)
                  MusicApi.Play
                  End Sub
                  💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                  Comment


                    #10
                    Thanks Rupp.
                    I am trying to get a list of artists.
                    Do you know if this is correct because I used to always get errors.

                    artist_list = MusicApi.LibGetPlaylists

                    Thanks!


                    ~Bill

                    Comment


                      #11
                      I hate vb.net...

                      ...
                      Dim artist_list As string
                      artist_list = MusicApi.LibGetPlaylists
                      ...


                      throws:

                      Scripting runtime error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Conversion from type 'String()' to type 'String' is not valid. at Microsoft.VisualBasic.CompilerServices.Conversions.ToString( Object Value) at scriptcode7.scriptcode7.Main(Object parm) --- End of inner exception stack trace --- at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at Scheduler.VsaScriptHost.Invoke(String ModuleName, String MethodName, Object[] Arguments)


                      ~Bill

                      Comment


                        #12
                        Bill;

                        Try

                        arrartist_list() = MusicApi.LibGetArtist("","")

                        this returns an array of artists. I haven't tried it but it might lead you to the right conclusion. I love vbs scripts 'cause they don't give you an error longer than the code that produced it.

                        Rupp:

                        Thanks, that seems to work.

                        Originally posted by Bill Brower View Post
                        Thanks Rupp.
                        I am trying to get a list of artists.
                        Do you know if this is correct because I used to always get errors.

                        artist_list = MusicApi.LibGetPlaylists

                        Thanks!
                        Don

                        Comment


                          #13
                          Thanks Don.
                          I'll try to dim artist_list as a string, if that doesn't work I'll try dimming it as an array.

                          Thank you everyone!


                          ~Bill

                          Comment


                            #14
                            Hey Greg:

                            Does this mean that there is no way to access this plugin with a vbs script? I can feel the headache coming on.... so many scripts, so little time.

                            Thanks;

                            Don

                            Originally posted by Rupp View Post
                            The newest Media Player plugin is a .net plugin and requires a vb.net script like the following:

                            Sub Main(parm as object)
                            Dim pi As Object
                            pi = hs.Plugin("Media Player")
                            Dim MusicApi As object
                            MusicApi = pi.GetMusicAPI(1)
                            MusicApi.Play
                            End Sub
                            Don

                            Comment


                              #15
                              Bump

                              Bump
                              Don

                              Comment

                              Working...
                              X