LiquidSoapPlayerClient.py 2.1 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from modules.communication.liquidsoap.LiquidSoapClient import LiquidSoapClient


class LiquidSoapPlayerClient(LiquidSoapClient):

    # ------------------------------------------------------------------------------------------ #
    def mixer(self, command, *args):
        if command == "status":
            return self.mixerstatus(*args)

        if command == "inputs":
            return self.mixerinputs()

        if command == "select":
            if len(args) == 2:
                return self.mixerselect(args[0], args[1])

        return "LiquidSoapPlayerClient does not understand "+command+str(args)

    # ------------------------------------------------------------------------------------------ #
    def mixerinputs(self):
        """
        List all channels on the mixer
        @type    namespace: string
        @param   namespace: lqs namespace
        @rtype:  list
        @return: answer of our lqs server
        """

        #        self.logger.info("listchannels modules/controller/liquidsoap.py")

        # send command
        self.command("mixer", "inputs")

        # convert to list and return it
        return self.message.strip().split(' ')


    # ------------------------------------------------------------------------------------------ #
    def mixerstatus(self, pos=""):
        """
        Get state of a source in the mixer
        @type    pos:       string
        @param   pos:       Mixerposition
        @rtype:  string
        @return: Response from LiquidSoap
        """
        self.command("mixer", "status", str(pos))
        return self.message

    # ------------------------------------------------------------------------------------------ #
    def mixerselect(self, pos, activate):
        """
        Kanal/Source aktivieren
        @type    pos:       string
        @param   pos:       Die Position
        @type    namespace: string
        @param   namespace: Namespace der Source
        @rtype:  string
        @return: Die Antwort des Liquidsoap-Servers
        """
        self.command("mixer", "select", str(pos) + " " + str(activate).lower())
        return self.message