Results 1 to 6 of 6

Thread: How to change this ajax/jQuery code to php (trying to get MPC web interface to work)

  1. #1
    Join Date
    Nov 2010

    How to change this ajax/jQuery code to php (trying to get MPC web interface to work)

    I am trying to get PHP to control MPC (Media Player Classic) using the web interface. This is the site im following:
    Anything using fsockopen wont work, I always get a blank page when I visit the .PHP page with no change to mpc (but using file_get_contents I can get the status.html page to give me info). Using fsockopen I have never received any error, I even tried fsockopen with a wrong random port to see what would happen, and it did give me an error (so it is apparently connection to MPC).

    I tried:
    1# Different ports
    2# Disabling firewall
    3# Different commands
    4# Several other HTML/javascript tools to confirm MPC HC is able to take commands
    5# Tried sending commands to /commands.html/ using GET instead of POST.
    6# Tried wireshare to see whats happening (but wireshark does not seem to pick up the packets)
    7# Tried removing the '@' to make sure there weren't warnings being hidden.

    Here is Javascript code that works:

    var data = new Object();
    data[wmcName] = commandId;
    if (paramName != undefined && paramName != null) {
    data[paramName] = paramValue;

    type: "POST",
    cache: false,
    data: data,
    url: '/command.html',
    success: function(data) {
    if (suppressRefresh != false) {
    error: function() {

    That code is running from: http://localhost:13579/ (which is the port that MPC is listening too, it also explains why the host/port is not specified).

    How can I make this work with PHP (in other words, I want php to POST content)? I am out of ideas, if I can't get this fixed here ill probably just get the js code to ajax some PHP before it ajax mpc (but I want to avoid that as it is more messy then a pure PHP solution)....

  2. #2
    Join Date
    Nov 2010

  3. #3
    Join Date
    Oct 2012
    Its to hard to do

  4. #4
    Join Date
    Jan 2009
    Do you have error reporting on? Is fsockopen disabled in your php.ini? Are you running the php through the MPC server/socket? The tutorial you showed doesn't have you doing that at but instead through Apache (probably since it is easier to debug any configuration/compatibility issues).

  5. #5
    Join Date
    Nov 2010
    Error reporting is on with E_ALL.
    fsockopen is not disabled (nothing listed in 'disable_functions')

    Are you running the php through the MPC server/socket?
    hmm, if I try to access anything PHP using the MPC port the PHP wont work (im not even sure how I would setup MPC to 'parse' PHP code). But if I access the same code using localhost without the port number the code will work (apache).

    Once again, if I purposely put in the wrong port in my PHP code, ill get an fsock error. So its like the fsock is connecting to MPC but for whatever reason the commands im sending are being ignored by MPC.

  6. #6
    Join Date
    Nov 2010
    suggestions on how to get this PHP code working?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
HTML5 Development Center