Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 5 of 5
  1. #1

    LMS-CLI: telnet - "playlist index +1" does not work

    Hi everyone,

    I am new to Squeezebox and am happy to have set up my first LMS with local Squeezelite on a RPi - with lots of help from your forum.

    Intended application:
    - run internet radio stations
    - user interface (with reduced user interaction)
    -- display lms "status_header.html" on MagicMirror
    -- control playlist of preferred stations via Apple remote A1156 (play/pause, volume up/down, next/previous station)

    Setup:
    - RPi 3b+
    $ cat /etc/debian_version
    10.10
    $ cat /etc/os-release
    PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
    - LMS via mysqueezebox.com/download
    Version: 8.1.1
    Platform: Debian/Ubuntu Linux ARM
    File: logitechmediaserver_8.1.1_arm.deb
    - Squeezelite on same RPi via
    $ sudo apt install squeezelite
    squeezelite is already the newest version (1.8-4.1+b1).
    - LMS and Squeezelite startup on boot
    - lirc to receive A1156 data and python script to send commands to LMS via telnet; python code for completeness of documentation of the issue
    Code:
    import lirc
    import time
    import telnetlib
    
    sockid = lirc.init("monitor", config_filename="~/App/SqueezeBoxIRController/monitor.lircrc", blocking=False)
    telnetid = telnetlib.Telnet("localhost", 9090)
    playpause = True
    
    while True:
        codeIR = lirc.nextcode()
        if codeIR != []:
            if codeIR[0] == "KEY_DOWN":
                    print "mixer volume -5"
                    telnetid.write("mixer volume -5 \r");
            elif codeIR[0] == "KEY_LEFT":
                    print "playlist index -1"
                    telnetid.write("playlist index -1 \r")
            elif codeIR[0] == "KEY_RIGHT":
                    print "playlist index +1"
                    telnetid.write("playlist index %2B1 \r")
            elif codeIR[0] == "KEY_UP":
                    print "mixer volume +5"
                    telnetid.write("mixer volume +5 \r");
            elif codeIR[0] == "KEY_MENU":
                    print "stop"
                    telnetid.write("stop\r")
                    playpause = False
            elif codeIR[0] == "KEY_PLAYPAUSE":
                    if playpause==True:
                            print "pause"
                            telnetid.write("pause\r")
                            playpause = False
                    else:
                            print "play"
                            telnetid.write("play\r")
                            playpause = True
            else:
                print codeIR
    
            time.sleep(0.05)
    Issue:
    - all commands work fine except for "playlist index +1" (resp. "playlist index %2B1") EVEN VIA COMMAND LINE (so no issue with the python part)
    -- e.g. with 2 stations in the playlist, "playlist index -1" will toggle correctly but "playlist index +1" will not do anything (well, playback stops for a moment but the same station keeps on playing)

    Minimum working example:
    Code:
    $ telnet localhost 9090
    Trying ::1...
    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.
    playlist index -1
    00%3A00%3A00%3A00%3A00%3A00 playlist index -1   
    playlist index +1
    00%3A00%3A00%3A00%3A00%3A00 playlist index %2B1   
    playlist index %2B1
    00%3A00%3A00%3A00%3A00%3A00 playlist index %2B1
    Is there another lms-cli command to get the next track in the playlist to play?

    Thx in advance.

    Keep save, Jens
    Last edited by thinkalready; 2021-08-18 at 23:43.

  2. #2
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    7,557

    LMS-CLI: telnet - "playlist index +1" does not work

    Are you sure this other station is not a m3u with multiple entries? LMS will display that as a single entry in the playlist but will iterate through the entries when next is requested


    EnvoyÚ de mon iPad en utilisant Tapatalk
    LMS 8.2 on Odroid-C4 - SqueezeAMP!, 5xRadio, 5xBoom, 2xDuet, 1xTouch, 1xSB3. Sonos PLAY:3, PLAY:5, Marantz NR1603, Foobar2000, ShairPortW, 2xChromecast Audio, Chromecast v1 and v2, Squeezelite on Pi, Yamaha WX-010, AppleTV 4, Airport Express, GGMM E5, RivaArena 1 & 3

  3. #3
    Hi philippe_44,

    thx for your ultrafast reply.
    It is an m3u. I just added some of the radio stations which come with LMS radio plugin.
    Let me check tonight how to add stations in a non-m3u way.

    I will update.

    Jens

  4. #4
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,598

    LMS-CLI: telnet - "playlist index +1" does not work

    > Is there another lms-cli command to get the next track in the playlist
    > to play?


    As Philippe suggested please check your content, as this command should
    just work. But you could indeed use "button fwd", which emulates the
    press of the FWD button on a remote or the device.

  5. #5
    To whomever is interested in my fix:
    In order to use the linked radio stations straight out of Squeezebox (m3u playlists), I instead changed my code from relative indexing (+1, -1) to absolute indexing.

    Code:
    import lirc
    import time
    import telnetlib
    import RPi.GPIO as GPIO
    
    sockid = lirc.init("monitor", config_filename="~/App/SqueezeIRControl/monitor.lircrc", blocking=False)
    
    while True:
        try:
            telnetid = telnetlib.Telnet("localhost", 9090)
    	break
        except:
    	print "telnet connection error: try again ..."
    playpause = False
    
    relaypin = 5
    
    #GPIO.cleanup()
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(relaypin, GPIO.OUT)
    GPIO.output(relaypin, GPIO.LOW)
    
    playidx = 0
    playcount = 0
    
    while True:
        codeIR = lirc.nextcode()
        if codeIR != []:
            if codeIR[0] == "KEY_DOWN":
            	print "mixer volume -5"
    		telnetid.write("mixer volume -5 \r")
    		tmp = telnetid.read_until("mixer volume -5")
    		print tmp
            elif codeIR[0] == "KEY_LEFT":
            	#print "playlist index -1"
    		#telnetid.write("playlist index -1 \r")
    		telnetid.write("playlist tracks ? \r")
    		telnetid.read_until("playlist tracks ")
    		playcount = int(telnetid.read_some())
    		playidx -= 1
    		if playidx<0:
    			playidx = playcount - 1
    		elif playidx>=playcount:
    			playidx = 0
    		telnetid.write("playlist index " + str(playidx) + " \r");
    		telnetid.read_until("playlist index");
    		playtmp = int (telnetid.read_some())
    		print "playlist index " + str(playtmp) + " (" + str(playtmp+1) + "/" + str(playcount) + ")"
            elif codeIR[0] == "KEY_RIGHT":
                	#print "playlist index +1"
    		#telnetid.write("playlist index %2B1 \r")
                    telnetid.write("playlist tracks ? \r")
                    telnetid.read_until("playlist tracks ")
                    playcount = int(telnetid.read_some())
                    playidx += 1
                    if playidx>=playcount:
                            playidx = 0
                    telnetid.write("playlist index " + str(playidx) + " \r");
                    telnetid.read_until("playlist index");
                    playtmp = int (telnetid.read_some())
                    print "playlist index " + str(playtmp) + " (" + str(playtmp+1) + "/" + str(playcount) + ")"                
            elif codeIR[0] == "KEY_UP":
                	print "mixer volume +5"
                    telnetid.write("mixer volume +5 \r")
    		tmp = telnetid.read_until("mixer volume")
    		print tmp
            elif codeIR[0] == "KEY_MENU":
    		print "stop"
    		telnetid.write("stop\r")
    		tmp = telnetid.read_until("stop")
    		print tmp
    		GPIO.output(relaypin, GPIO.LOW)
    		playpause = False
            elif codeIR[0] == "KEY_PLAYPAUSE":
    		if playpause==True:
    			print "pause"
    			telnetid.write("pause\r")
    			tmp = telnetid.read_until("pause")
    			print tmp
    			playpause = False
    		else:
    			print "play"
    			GPIO.output(relaypin, GPIO.HIGH)
    			telnetid.write("play\r")
                            tmp = telnetid.read_until("play")
    			print tmp
    			playpause = True
    	else:
    	    print codeIR
    #    else: # codeIR == []
    #    	print "nothing to do"
    
        time.sleep(0.05)
    
    GPIO.cleanup()

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •