The remote now uses AJAX so it seams if the page isn't refreshed when you click on a button.

There is still a bug: CH+ and VOL+ do not work, please take a look at this!

Wout


SourceForge.net wrote:
Feature Requests item #1624110, was opened at 2006-12-29 10:00
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=446898&aid=1624110&group_id=46652

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Freevo Web
Group: Freevo 1.x series
Status: Open
Priority: 5
Private: No
Submitted By: Frank Naude (naudefj)
Assigned to: Nobody/Anonymous (nobody)
Summary: WebRemote for Freevo's Webserver

Initial Comment:
Attached is a simple WebRemote for freevo's webserver. Please review and submit to SVN.
Install instructions:

1. Copy webremote.rpy (attached) to freevo-1/src/www/htdocs/
2. Recompile and restart Freevo
3. Navigate to http://localhost:8080/webremote.rpy to test


----------------------------------------------------------------------

You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=446898&aid=1624110&group_id=46652

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-devel mailing list
Freevo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-devel


#!/usr/bin/python
# -----------------------------------------------------------------------
# webremote.rpy - The main index to the web interface.
# -----------------------------------------------------------------------
# $Id: webremote.rpy 8551 2006-12-28 08:08:28Z naudefj $
#
# Notes:
# Todo:
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002 Krister Lagerstrom, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------

import util, config
import socket
from www.web_types import HTMLResource, FreevoResource

class WebRemoteResource(FreevoResource):

    def _render(self, request):
        fv   = HTMLResource()
        form = request.args

        if not (config.ENABLE_NETWORK_REMOTE == 1 and 
config.REMOTE_CONTROL_PORT):
            fv.res += """
            The WebRemote is currently disabled.<br/><br/>
            To enable, add the following settings to your local_conf.py file 
and restart freevo:<br/>
            <ul>
                <li>ENABLE_NETWORK_REMOTE = 1</li>
            <li>REMOTE_CONTROL_HOST = '127.0.0.1'</li>
            <li>REMOTE_CONTROL_PORT = 16310</li>
            </ul>
            """
            return String( fv.res )

        code = fv.formValue(form, 'code')
        if code:
            if code == 'OK':     code = 'SELECT'
            if code == 'BACK':   code = 'EXIT'
            if code == 'RIGHT>': code = 'RIGHT'
            if code == '<LEFT':  code = 'LEFT'
            if code == '<REW':   code = 'REW'
            if code == 'FFWD>':  code = 'FFWD'
            #The following codes do not work yet!
            if code == 'VOL_UP': code = 'VOL+'
            if code == 'CH_UP': code = 'CH+'
            
            
            host = config.REMOTE_CONTROL_HOST
            port = config.REMOTE_CONTROL_PORT
            buf  = 1024
            addr = (host,port)

            UDPSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
            UDPSock.sendto(code, addr)
            UDPSock.close()

        fv.res += """
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<head>
   <title>Freevo | WebRemote</title>
   <meta http-equiv="Content-Type" content= "text/html; charset=UTF-8"/>
   <link rel="stylesheet" href="styles/main.css" type="text/css" />
   <style>
    body  { background: #666699; }
    h3 { color: white; }
    input { width:100% }
    table { width: auto; }
    td    { padding: 1px; }
    input.remote { width: 65px; height: 20px; background: #eee; font-size: 
12px; }
    input.remote:hover { background: #fed; }
   </style>
</head>

<body>

<script language="JavaScript" type="text/javascript">
<!--
   window.resizeTo(240,500)
   window.toolbar.visible     = false
   window.statusbar.visible   = false
   window.scrollbars.visible  = false
   window.personalbar.visible = false

    var xmlHttp = false;

    function getXMLHttpObject () {
      try {
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");          // Internet 
Explorer 1ste poging
      } catch (e) {
        try {
          xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");     // Internet 
Explorer 2de poging
        } catch (e2) {
          xmlHttp = false;
        }
      }

      if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
        xmlHttp = new XMLHttpRequest();                         // Mozilla, 
Firefox, Opera, ...
      }
    }

    function send_code( code ) {
      getXMLHttpObject();

      var url = "remote.rpy" + "?code=" + code;
       
      xmlHttp.open("GET", url, true);
      xmlHttp.send(null);
    }
-->
</script>

<center>
<h3>Freevo WebRemote</h3>

<form name="remote">
<table border="0" cellspacing="1" cellpadding="0">

<tr><td>&nbsp;</td>
    <td><input class="remote" type="button" onClick="send_code('UP');" 
name="code" value="UP"></td>
    <td>&nbsp;</td>
</tr>
<tr><td><input class="remote" type="button" onClick="send_code('<LEFT');" 
name="code" value="<LEFT"  class="remote"></td>
    <td><input class="remote" type="button" onClick="send_code('OK');" 
name="code" value="OK"     class="remote"></td>
    <td><input class="remote" type="button" onClick="send_code('RIGHT>');" 
name="code" value="RIGHT>" class="remote"></td>
</tr>
<tr><td>&nbsp;</td>
    <td><input class="remote" type="button" onClick="send_code('DOWN');" 
name="code" value="DOWN"   class="remote"></td>
    <td>&nbsp;</td>
</tr>

<tr style="line-height: 8px;"><td colspan=3>&nbsp</td></tr>

<tr><td><input class="remote" type="button" onClick="send_code('BACK');" 
name="code" value="BACK"></td>
    <td><input class="remote" type="button" onClick="send_code('DISPLAY');" 
name="code" value="DISPLAY"></td>
    <td><input class="remote" type="button" onClick="send_code('MENU');" 
name="code" value="MENU"></td>
</tr>

<tr style="line-height: 8px;"><td colspan=3>&nbsp</td></tr>

<tr><td>&nbsp;</td>
    <td><input class="remote" type="button" onClick="send_code('PLAY');" 
name="code" value="PLAY"></td>
    <td>&nbsp;</td>
</tr>
<tr><td><input class="remote" type="button" onClick="send_code('<REW');" 
name="code" value="<REW"></td>
    <td><input class="remote" type="button" onClick="send_code('PAUSE');" 
name="code" value="PAUSE"></td>
    <td><input class="remote" type="button" onClick="send_code('FFWD');" 
name="code" value="FFWD>"></td>
</tr>
<tr><td>&nbsp;</td>
    <td><input class="remote" type="button" onClick="send_code('REC');" 
name="code" value="REC" style="color:red"></td>
    <td>&nbsp;</td>
</tr>

<tr style="line-height: 8px;"><td colspan=3>&nbsp</td></tr>

<tr><td><input class="remote" type="button" onClick="send_code('VOL_UP');" 
name="code" value="VOL+"></td>
    <td><input class="remote" type="button" onClick="send_code('MUTE');" 
name="code" value="MUTE"></td>
    <td><input class="remote" type="button" onClick="send_code('CH_UP');" 
name="code" value="CH+"></td>
</tr>
<tr><td><input class="remote" type="button" onClick="send_code('VOL-');" 
name="code" value="VOL-"></td>
    <td>&nbsp;</td>
    <td><input class="remote" type="button" onClick="send_code('CH-');" 
name="code" value="CH-"></td>
</tr>

</table>
</form>
</center>
</html>
        """

        return String( fv.res )

resource = WebRemoteResource()

                 
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-devel mailing list
Freevo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to