Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Is there a way to select the Player by giving a parameter in the URL #33

#1

I have only recently really started using RompR. One of the minor inconvenience I have is selecting the player. I have defined multiple players in the setup (one for each room). These are mostly raspberry pi kind of devices running mpd. Let us say I have selected player 1 now. I listen to few songs and then power off the device before going to sleep. Next day morning I am in a different room. When I invoke rompr, it takes a minute or so before showing the setup screen after timing out trying to establish a connection to port 6600 on the first device. I know which player I need to select. So if one can invoke rompr like this, it would be great. Is it possible to do something like this?

http://path_to_rompr/?current_host=xyz

  • solved #6
  • replies 7
  • views 922
  • likes 2
#2

You are certainly unusual in switching things off at night :) But that is to be applauded.

This is not as straightforward is it might seem though, since the player selection is set as a cookie.

One hacky way to do it would be to use the Developer tools in your browser to modify the cookie, but that's horrible and I wouldn't reccommend it.

The thing I'd suggest doing is to remember to leave rompr connected to a different machine before you power one down.

"leave rompr connected to a different machine before you power one down" is what I have been doing. But what has been happening lately with me is that I have been listening to music very late in the night and when I am about to drop dead, I just press the switch off button that shuts off power to mobile charger connected to a nexus 6p running rompr and a raspberry pi2 connected to an IEM. Since you revealed that this is a cookie thing, I did some google and learned some tiny bit of php and how to pass parameters in the url. So I did a tiny change in index.php and it works for me. Now I can do the following

http://ip_of_rompr_host/rompr?currenthost=xxxx

This is by creating 4 shortcuts on my mobile device, each shortcut having a different currenthost parameter.
This is what I have added to index.php

if (isset($_GET['currenthost'])) {
    setcookie('currenthost',$_GET['currenthost'],time()+365*24*60*60*10,'/');
    $prefs['currenthost'] = $_GET['currenthost'];
}

The only minor issue is that I get a wrong "Connected to" message from player/mpd/controller.js
I think the code in controller.js "Connected to "+getCookie('currenthost')+" (" gets called before the cookie gets set in index.php. But I don't understand these things and for the time being it works for me :slight_smile:

#4

interesting. I suspect there’s a timing thing going on and what you probably need to do is to set the cookie and then send a temporary redirect header to force the page to reload. In any case your proof of concept is a good start, I’ll look into making this a permanent feature.

#5

That would be a really useful feature to have it permanently. It has increased the usability by leaps and bounds. After reading plenty of articles on stack overflow on how to reset the url, I came across this post https://stackoverflow.com/questions/11317546/reset-url-on-form-submit.

With the help of the above post I made the followig change in index.php and now the whole thing works beautifully for me. Even the transfer playlist now works. Earlier that had stopped working without the redirect. This is the change i made. I don't knnow if what I have done doesn't have bugs, but it is working.

if (isset($_GET['currenthost'])) {
    setcookie('currenthost',$_GET['currenthost'],time()+365*24*60*60*10,'/');
    $prefs['currenthost'] = $_GET['currenthost'];
    $_SESSION['redir'] = true;
    header("Location: /rompr/", true, 303);
    exit;
} else
if (isset($_SESSION['redir'])) // We have redirected!
{
    unset($_SESSION['redir']);
    http_response_code(201); // Acknowledge receiving the form data.
}
#6

Based on your work I've added this as a permanent feature in the upcoming 1.48 release. Thanks.

mbhangui accepted post #6 as the answer
#7
#8

I have been using this since last 4 days. Works great. Thank you. RompR is my default player on my phones and tablets. I even tried it on my amazon firestick connected to a 65" plasma tv (tablet skin with firefox browser). It works, but I gave up because using the tv / firestick remote is painful.