Any suggestions for implementing some kind of web interface?
Home › Forums › General Discussion › Any suggestions for implementing some kind of web interface?
- This topic is empty.
-
AuthorPosts
-
June 12, 2011 at 10:24 am #23641Mug-whyParticipant
Hi everyone,
Great site, great project! 🙂
My family and I are avid users of WiiMC as our media center. We have a home setup where it plays music and video from a share over our LAN using a projector and speakers. When playing music, what we tend to do is to turn on the projector (so we can see the GUI and make selections), wait, select the playlist, begin it, turn off the projector. When we want to change anything that’s playing, or create/choose another playlist this involves turning on the projector again, waiting etc etc.
So what I would really like, is some kind of ability to control WiiMC over the LAN, probably some kind of web interface (as this could then be used with anything with a browser, e.g. android phones/tablets, laptops). I have looked quite carefully and haven’t seen anything like this available though. Am I missing something?
At least two other posts on this forum (these are all I found anyway) have made this kind of suggestion:
http://www.wiimc.org/forum/viewtopic.php?f=6&t=1380
http://www.wiimc.org/forum/viewtopic.php?f=6&t=622I know that the MPlayer underneath all this is very flexible in terms of remote control:
http://www.mplayerhq.hu/DOCS/tech/slave.txt
…and indeed GeeXBoX for Wii says it implements an http based web interface:
http://farter.users.sourceforge.net/geexboxforwii/usage/networking/
… of course, I would like to have this ability with the excellent WiiMC instead.Basically, this post is to see if I am missing something, or if someone has any suggestions. There seem to be so many great extensions and 3rd party solutions for the WiiMC so it is a surprise to me that this hasn’t already been done somewhere.
I wonder if this could be implemented based around writing files/pipes to the LAN share that then WiiMC sees as per:
http://code.google.com/p/wiimc/source/browse/trunk/libs/libmpg123/doc/README.remote?spec=svn625&r=625Thanks very much,
fttb.June 12, 2011 at 12:37 pm #29218hello2000ParticipantI think this would involve embedding an HTTP server into WiiMC, thus spending precious RAM and processor on a feature not everyone would use.
While I say a HTTP web/lan interface would be difficult, I think a simple protocol for controlling WiiMC remotely, and tell it to play files and such, like Apple’s AirPlay, would be good. Obviously, it wouldn’t work on every device with a browser: you’d need to code a client for that protocol for every device you wanted to control WiiMC from. That means: an app for Windows, other for Android, other for (jailbroken) iPhone, other for Linux Destkop, and perhaps even one for Wiis so people with two Wiis could control what one Wii is playing from the other.
This solution I propose, while putting less load on the Wii that’s running WiiMC (listening on a port for commands and replying with status takes less resources and is less difficult than a full HTTP server plus the web interface in CGI – because PHP would be “impossible”), leads to more work on every other device: we’d need to code for Windows, Linux, Android, iOS, Windows Mobile, and everything we wanted to control WiiMC from.I’m also interested in controlling WiiMC remotely (no matter if it’s through browser or a dedicated app) and so I’m waiting for a reply from someone who knows better the WiiMC code and the Wii in general than me 🙂
June 12, 2011 at 1:11 pm #29219Mug-whyParticipantExactly.
To be clear, while embedding an http server and interface in WiiMC would allow for a very general level of control, I appreciate the extra difficulty involved. I wasn’t really suggesting this.
I was thinking instead, as a simpler to implement alternative solution, just the ability for other applications to feed commands to a pipe/file stored somewhere “generally available” – such as a file on a LAN share, as per:
http://code.google.com/p/wiimc/source/browse/trunk/libs/libmpg123/doc/README.remote?spec=svn625&r=625My understanding is that doing this in conjunction with somehow activating/configuring “slave mode” in mpg123 (which seems to sit within WiiMC) would allow other applications to control WiiMC by simply writing to this file/pipe.
I was really hoping that someone with more ability had already tried to do this! 😉
Thanks,
fttb.June 12, 2011 at 3:34 pm #29220hello2000ParticipantI think that remote interface in libmpg123 only works if it is compiled as a standalone app, for example, on a Linux package – not the case with WiiMC. Plus, at the very least, that remote interface would only control the files played by libmpg123.
About setting up a LAN share and put a file there… I don’t think that’d be the best protocol solution possible: IMO it’d more simple to just code a port listener that listens on e.g. 3.4.5.6:9000 (being 3.4.5.6 the Wii’s IP, and 9000 the port it listens in), and replies with simple commands to the client who made the request on that port.
Here’s a imaginative connection log between the client and WiiMC: 😀
CLIENT (192.168.1.2): Connecting to 192.168.1.3...
CLIENT (192.168.1.2): Connected, sending: 603 (CONTROL_NEXT_TRACK)
Reply from WIIMC (192.168.1.3): 200 (OK)
CLIENT (192.168.1.2): Disconnected.
... 5 minutes later...
CLIENT (192.168.1.2): Connecting to 192.168.1.3...
CLIENT (192.168.1.2): Connected, sending: 660 SD:/Music/Song 1.mp3 (PLAY_FILE SD:/Music/Song 1.mp3)
Reply from WIIMC (192.168.1.3): 200 (OK)
CLIENT (192.168.1.2): Sending: 660 SD:/Music/Song 45.mp3 (PLAY_FILE SD:/Music/Song 45.mp3)
Reply from WIIMC (192.168.1.3): 404 (FILE_NOT_FOUND)
CLIENT (192.168.1.2): Sending: 699 STANDBY (SHUTDOWN FORCE_STANDBY)
As you can see from my stupid example of communication log, the protocol looks like HTTP, but it’s not. And it would allow more than playing control: it could also tell the Wii to shutdown, to eject the disc, etc.
Basically, I have the idea for the protocol in my head but I don’t know how code it. Although not having enough knowledge to code the WiiMC server part, I could code the Windows client in .NET (probably the only language I have real experience with is VB.NET). But for that, someone need to code the server for WiiMC 🙂
jhb50, are you willing to deploy something like described in this thread in your extension pack? It could be a great addition if it’s not too much work (I guess it is).
Regards
GabrielJune 12, 2011 at 4:28 pm #29221cadbuscaParticipantI don’t understand your problem. WIIMC is up and running. When you turn off the projector isn’t the same screen still there when you turn it back on? I assume you are turning it off to save power, because otherwise the screensaver will turn on to prevent any static images. And I assume you are turning it back on because WIIMC can only be controlled by clicking items on the screen. You can avoid turning it back on in many cases by using the Remote PlayMusic Mode within WIIMC+ which enables the WIIMOTE to perform the control functions within a WIIMC playlist. All you need to do is add multiple .m3u playlists to the WIIMC playlist when you start and you need never turn on the projector again.
46) Remote Play Music Mode
==========================
This enhancement adds a fourth “Start Remote Mode” option to the music playlist menu that puts WIIMC+ in screensaver mode while playing a playlist and the allows the down, up, right and left buttons to control the playback functions while the artist name, song title and album display on the screen. The +/- volume control buttons remain active in this mode and clicking the B-button returns to the Music playlist menu. Right skips to the Next Selection, Left restarts the current selection, Up toggles Continuous/Shuffle mode and Down toggles Play/Pause. This option allows remote control of WIIMC audio playback when the screen is not visible but within Wiimote range, or when use of the Wiimote buttons is preferable to pointing the Wiimote at the audiobar icons. (or when you want to turn off the projector)June 12, 2011 at 5:12 pm #29222hello2000ParticipantSo there’s already a solution in WiiMC+ which allows you to control WiiMC+ withtin a distance of 10 meters from your Wii… not the perfect solution if your home is big, but eliminates the need for coding a server to run along with WiiMC and possible clients depending on the server implemented.
And hey, you can just buy a small LCD with A/V in and connect the Wii to it while playing WiiMC instead of the less-power-efficient projector. And you can turn the LCD on/off at the click of a button, without waiting for the projector bulb to light up. That is, if you wanna buy a LCD just for that purpose 🙂
“Focus on the solution, not on the problem.”
June 12, 2011 at 5:18 pm #29223Mug-whyParticipantHi jhb50, thanks for dropping by, and thanks for your suggestion. 🙂
Its not really a “problem” – there are lots of reasons why a remote interface would be helpful and fun, this is just one.
But to explain my particular situation: I turn off the projector to save bulb life (we are often playing music this way for most of the day), because it gets very hot, and because it makes noise when its running. And the issue is that it takes quite a bit of time for the thing to turn itself off and on, and its in a slightly inconvenient location etc.
Also, while its an excellent feature to be able to use the WiiMote to do things within a playlist(s) as you have described, if I want to select something that is not within what has been set up initially (or do anything more complicated than what you have described) then I need to turn on the projector to see what I’m doing. Also, in doing what you have described I am limited in terms of range of the WiiMote. And it would just be amazingly cool to be able to control WiiMC from other PC’s on the LAN (e.g. smartphone/tablet)… 😀
Certainly I could buy something like a small LCD screen with A/V connectors (less common than you’d think), but this would still be less cool than being able to control WiiMC from anything on the LAN. 😉
Anyway, I am sure there are a multitude of different reasons that the other users interested in seeing this feature can supply as well.
What do you think of Gabriel’s suggested approach below?
Can you see any way to use the “slave” facility (e.g. described here http://code.google.com/p/wiimc/source/browse/trunk/libs/libmpg123/doc/README.remote?spec=svn625&r=625) so that WiiMC would respond to commands written to it in a file/pipe in some shared location?
Thanks for your time.
Regards,
fttb.June 12, 2011 at 6:51 pm #29224cadbuscaParticipantI’m not a developer so I can’t comment on doing that. All my mods have been extensions of the existing WIIMC code based on their implementations. I doubt you will see any such feature so the separate monitor is probably your best way.
June 13, 2011 at 12:44 am #29225Mug-whyParticipantOk, thanks.
After having a look at the code in the repository I may have some small idea what is going on. Would appreciate any thoughts/comments…
Seems like the MPlayer underneath WiiMC is being given commands via mp_input_queue_cmd() (in …/mplayer/input/input.h) and various other hooks in …/mplayer/mplayer.c (e.g. lines 4726-):
http://code.google.com/p/wiimc/source/browse/trunk/source/mplayer/mplayer.c
/****************************************************************************
* Wii hooks
***************************************************************************/
void wiiLoadFile(char *_filename, char *_partitionlabel)
{
if (partitionlabel)
free(partitionlabel);
partitionlabel = (_partitionlabel) ? strdup(_partitionlabel) : strdup("");
if(filename)
free(filename);
filename = strdup(_filename);
}
void wiiGotoGui()
{
mp_cmd_t * cmd = calloc( 1,sizeof( *cmd ) );
cmd->id=MP_CMD_QUIT;
cmd->name=strdup("quit");
mp_input_queue_cmd(cmd);
}
void wiiPause()
{
mp_cmd_t * cmd = calloc( 1,sizeof( *cmd ) );
cmd->id=MP_CMD_PAUSE;
cmd->name=strdup("pause");
mp_input_queue_cmd(cmd);
}
etc...
The “main loop” is in …/wiimc.cpp (lines 708-):
http://code.google.com/p/wiimc/source/browse/tags/1.1.8/source/wiimc.cpp
// create GUI thread
while(1)
{
ResetVideo_Menu();
WiiMenu();
if(ExitRequested)
break;
MPlayerMenu();
}
// application exiting
StopGX();
UnmountAllDevices();
etc...
What this seems to be doing is using WiiMenu() to find out what kind of file to play, then handing control to MenuBrowse() to select the particular file etc, then using the …/mplayer/mplayer.c hooks above.
There seem to be various threads active, some for the GUI’s, some for MPlayer.
Seems to me the theoretical solution would be to:
* include source from something like WiiWebServer (http://wiibrew.org/wiki/Wii_Web_Server);
* somewhere in wiimc.cpp before the main loop, fire up another thread that sleeps most of the time but listens occasionally to the httpd, and serves some kind of logfile (which could perhaps be an echo all the stdio output?), and implements a few simple commands (using the “hook” calls above) based on what it receives.That would be a start anyway.
This is a pretty ambitous thing for me to contemplate (I mainly use VB/excel). Does this interest anyone? Does this sound sensible/insane?
Cheers,
fttb.June 13, 2011 at 10:47 am #29226hello2000ParticipantI think that any kind of controlling interface should control the WiiMC interface and not directly MPlayer, because if it controlled MPlayer directly, it would override any playlists and even certain options. The only result of controlling MPlayer directly is random crashes and MPlayer unexpectedly switch, for example, from a YouTube video to a music file “because someone on your LAN wanted to listen to a music file while you were vieweing YouTube” (that’s another thing that could be implemented in the future: permissions control and priorities from one user to another).
About the web server to use if the solution adopted is to use a complete HTTP server (and not just a port listener for a specific protocol), I fear there isn’t anything developed and stable well enough for the Wii. WiiWebServer is still in alpha stage and I don’t think it’s being actively developed, or that it’ll ever be again. And even if WiiWebServer is stable serving static HTML pages, then how would the static HTML files control WiiMC? And how would the page display, for example, the playlist (or at least the now playing information)? It would need, at least, CGI, but WiiWebServer has no CGI AFAIK. Plus, lets imagine all these problems were solved, but one thing remains: the Wii has low RAM, and a http+cgi server would take a great amount of RAM to function properly – and that amount varies, so it can’t be a static buffer allocated in RAM. Again, all I can imagine with an http server embedded in WiiMC is either a very small buffer for video and audio playback, or random lockups.
And I was just writing this when I remembered of other factor: the Wii’s wireless card is not the fatest and stablest of things, and serving rich HTML pages while, at the same time, downloading online media can draw both operations (download and upload) very slow. But that’s something a more experienced person can confirm.In fact, this is a pretty ambitious thing for anyone: too much projects and no work (neither experience!). Plus, I can’t manage to compile WiiMC on Linux, and I just put my Windows install to work, doing a massive uninstallation of things, and I don’t want to lock up the Windows again by having to install Tortoise SVN, devkitpro, and another handful of things that will most likely put my Windows install slow and unusable again – for some reason I switched to Linux…
I also have few experience in C nor C++, since I switched to Linux (and left .NET on Windows) I haven’t really restarted to code anything. That, plus the fact of not managing to setup the build environment for WiiMC…
Cheers
GabrielJune 16, 2011 at 4:06 pm #29227Mug-whyParticipantWell, I’m not as negative about this as you are Gabriel. 😉
I think most of the usage issues you mention are fairly easily dealt with (activation of this ‘listening’ feature as an option at the Wii, or else some kind of simple password system would prevent control conflicts).
I do like your idea of a simple port listener and a basic protocol – certainly I am not thinking of cgi! I am really only interested in implementing a single command – being able to tell it to start playing a nominated file via the LAN (presumably http). In terms of what the http server would serve, as I said, just some kind of logfile to show whats going on would be enough (would likely only be used to diagnose problems). So this doesn’t seem like it would be too much of an additional load for the Wii.
Also, bear in mind that GeeXBox for the Wii includes telnet, ftp and http servers (http://farter.users.sourceforge.net/geexboxforwii/usage/networking/), so it doesn’t sound like its impossible for the Wii to do this kind of thing in addition to playing files.
Also, ideally this would not be “controlling MPlayer directly” – above I am trying to understand the calls that WiiMC uses to MPlayer, so I see it as equivalent to what is activated by the WiiMC menu functions. But in terms of testing the concept, better to get something/anything working and then refine it.
Anyway, I have been slowly downloading/installing/testing the necessary bits to compile WiiMC on my windows system so I can have a go at this. So I am interested in your experience trying to compile. I understand you have still not managed to compile in linux (http://www.wiimc.org/forum/viewtopic.php?f=5&t=1378&hilit=compiling+instructions), did you ever successfully compile under windows?
Cheers,
fttbJune 16, 2011 at 10:51 pm #29228cadbuscaParticipantUse my guide plus the precompiled stuff in the WIIMC+ pack.
-
AuthorPosts
- You must be logged in to reply to this topic.