Announcement

Collapse
No announcement yet.

I need help with my little project at ams

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • I need help with my little project at ams

    Greetings forum members, programmers and asuaries.
    I am creating an interactive discography project, although I have been able to create all the functions I needed, there is one specifically where I got stuck. I explain:

    I want to have two modes of reproduction, the first when I click on the title of the song (that is already achieved) and the second (it is where I am stuck) by clicking on a button I can play the entire disc, that is, the songs sound sequentially. Lua is new to me, however I have knowledge of other programming languages that have helped me with this one.

    The code or routine for this function that I found on the AMS help pages

    audio_count = 1;
    audio = {
    "Autoplay\\Audio\\audio_file1.ogg",
    "Autoplay\\Audio\\audio_file2.ogg",
    "Autoplay\\Audio\\audio_file3.ogg"

    };
    Audio.Load(CHANNEL_USER1, audio[audio_count], true, false);
    if e_State == "Finish" then
    audio_count = audio_count + 1;
    if audio_count < Table.Count(audio)+1 then
    Audio.Load(CHANNEL_USER1, audio[audio_count], true, false);
    end
    end



    The only thing that this routine achieves is to reproduce the first song but it does not continue playing the subsequent songs. I even made a modification, rather a simplification of this routine by making a llistbox and creating a loop, achieving the same result (it plays only the first song).


    for Ncount = 1,3 do

    result = ListBox.GetItemData("ListBox1", Ncount);
    Audio.Load(CHANNEL_USER1, result, true, false);
    if e_State = "Finish" then
    Ncount = Ncount + 1;
    end

    end


    I really don't know the e_State "Finish" statement.
    As I understand it is very Lua, it uses the variants that e_state offers to perform various audio functions. However, by performing some tests, such as eliminating this instruction, the loop is completely fulfilled, achieving that only the last theme or song is played. Which to my logic tells me that the problem is in the e_state instruction. Apparently this breaks the routine or loop.

    I am very grateful to those programmers or users with vast knowledge in Lua or AMS, and know what the problem is, enlighten me, since I have been stuck for more than a month in that single problem. Everything else is done.

    Thank you all in advance, and have a great day.

  • #2
    Pasting pieces of Lua script into a forum post does not help when you do not state clearly where this code was written. This is why I previously asked you to attach the (*.apz) file to the post. The part with
    Code:
    if e_State == "Finish" then
    -- some loop here
    end
    needs to be written in the On Audio event script tab, as it is there where the e_State variable is defined and set - have you done this? We don't know...

    Click image for larger version

Name:	SCRN-2021-01-07-03.png
Views:	135
Size:	11.0 KB
ID:	305947

    Ulrich

    Comment


    • #3
      Greetings friend Ulrich. First of all I thank you for answering my problem.

      The problem appears to be in the e_State command. I had no idea that it should be declared somewhere other than where I'm writing the code for the function I want to create.

      I explain in more detail the code that I reviewed above is written in the script of the button that will play the entire disc, that is, if there are 10 songs, I want them to be played one by one sequentially. Then I will need to declare the variable and configure it in the ON AUDIO tab of the properties of the page in question.

      What would be the correct declaration of the variable?

      1) e_State = ""
      2)


      Is this the correct way to declare this variable?

      Another is that I'm not sure how to configure it, that is, I put in the programming in the same script as the start play button. The e_State instruction not with a loop but with the if conditional:

      if e_State == "Finish" then
      count = count + 1
      end


      Would this be the configuration you are referring to ???

      Again, I thank you for your time and attention. I have partly managed to clear up some doubts, now I just need to know correctly how to declare this variable, configure it and insert it in the small programming code so that the button plays the songs on the disc. Happy day to you

      Comment


      • #4
        If you had followed the code in the help file you should not have had a problem
        in Globals
        Code:
        -- will keep track of the audio files
        audio_count = 1;
        
        --loads desired audio files into a table
        audio = {
        "Autoplay\\Audio\\audio_file1.ogg",
        "Autoplay\\Audio\\audio_file2.ogg",
        "Autoplay\\Audio\\audio_file3.ogg"
        };
        your Button On Click
        Code:
        Audio.Load(CHANNEL_USER1, audio[audio_count], true, false);
        --loads audio file and plays auto

        your page On Audio
        Code:
        if e_State == "Finish" then
        audio_count = audio_count + 1;
        --ensures a valid file will be loaded
        if audio_count < Table.Count(audio)+1 then
        Audio.Load(CHANNEL_USER1, audio[audio_count], true, false);
        end
        end
        I have done an example but file is a little too big to post here so here is link:
        https://ln2.********/dl/ef641f0f0/hs...p88mb-xkudya2w

        Cheers

        Comment

        Working...
        X