Example #1
0
        public IrisSound parseSound()
        {
            IrisSound sound = new IrisSound();
            String    fieldName, fieldValue;

            nextTokenIfEquals(Token.TokenValue.SOUND);

            if (currentTokenEquals(Token.TokenValue.VALUE_IDENTIFIER))
            {
                sound.name = currentToken.stringValue;

                nextToken();

                nextTokenIfEquals(Token.TokenValue.LBRACE);

                while (!currentTokenEquals(Token.TokenValue.RBRACE))
                {
                    if (currentTokenEquals(Token.TokenValue.VALUE_IDENTIFIER))
                    {
                        fieldName = currentToken.stringValue;

                        nextToken();

                        nextTokenIfEquals(Token.TokenValue.EQ);

                        if (fieldName.Equals("source"))
                        {
                            if (currentTokenEquals(Token.TokenValue.STRING))
                            {
                                fieldValue = currentToken.stringValue;

                                nextToken();

                                nextTokenIfEquals(Token.TokenValue.SEMICOLON);
                                sound.setSource(fieldValue);
                            }
                            else
                            {
                            }
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        throw new SyntaxError(lineNumber, colNumber, Token.TokenValue.VALUE_IDENTIFIER);
                    }
                }

                nextTokenIfEquals(Token.TokenValue.RBRACE);
            }
            else
            {
                throw new SyntaxError(lineNumber, colNumber, Token.TokenValue.VALUE_IDENTIFIER);
            }

            return(sound);
        }
Example #2
0
        public void addSound(IrisSound sound)
        {
            if (sounds == null)
            {
                sounds = new List <IrisSound>();
            }

            sounds.Add(sound);
        }
Example #3
0
        public void playMedia(IrisSound sound)
        {
            if (sound != null)
            {
                if (player.Source != null)
                {
                    player.Close();
                    player.Source = null;
                }

                player.Source = sound.soundPath;
                player.Play();
            }
        }