Looking for suggestions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • TJ_Tigger
    Indigo Rose Customer
    • Sep 2002
    • 3159

    Looking for suggestions

    In a project I am currently working on I have a music directory with MP3s that will be use in the project. I also have a list box that will contain the above mentioned MP3s for selection if the user so desires. My problem is this. I want a dynamic list in the List box, rather than a static list of songs. That way I can reuse or add additional songs without having to worry about what is in the list box. I also have the list box hidden from view until such a time that the user wants to load a new song. Therein lies the problem. On a page show I have the application build a list and populate the list box and then hide the list box. Sometimes, if I have a lot of things going on on the computer, it will fail to load the songs into the list box if the list box is hidden before it can actually add the songs.

    I am running XP on a 2G processor with 256 MB RAM. And it occasionally does this, I would say maybe one out of every 6-8 times. Other than making a static list does anyone have a suggestion on what to do to make sure the list box is populated before the list box is hidded. I am worried that the Educational PCs that this will be running on are definately slower than mine and I assume they will run into a similar problem more frequently.

    Would a While loop work. I know that loops will run at different speeds on the PCs but what if I were to do something like this:

    %Files% = GlobalList(playlist),GetItem (All)
    <font color=blue>add</font color=blue>
    ListBoxObject(ListBox1),AddFiles (Start, "%Files%")
    %ItemCount% = ListBoxObject(ListBox1), GetProperty ("Item Count")
    <font color=blue>IF (%ItemCount% = 0)</font color=blue>
    GOTO ("add")
    <font color=blue>END IF</font color=blue>
    Page.HideObject("ListBox1")

    Would that prevent the list box from being hidden until there was something in it? The Global list is created upon project initialization for automatic play of songs. I figured instead of doing another search for .mp3 I would utilize what was already there.

    Or here is another:

    %Files% = GlobalList(playlist),GetItem (All)
    %ItemCount% = "0"
    <font color=blue>WHILE (%ItemCount% = 0)</font color=blue>
    ListBoxObject(ListBox1),AddFiles (Start, "%Files%")
    %ItemCount% = ListBoxObject(ListBox1), GetProperty ("Item Count")
    <font color=blue>END WHILE</font color=blue>
    Page.HideObject("ListBox1")

    Which do you think would be the best to populate a list box and hide it once it has the files listed in it. OR is there a better way that you could suggest to me.

    Tigger
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine
  • Derek
    Indigo Rose Customer
    • May 2001
    • 1254

    #2
    Re: Looking for suggestions

    Tigg - does the listbox need to be populated before it's hidden? would it not work for you if yu have:

    //at the desired time on startup etc
    Page.Hideobject[Listbox1] - even if it is empty

    //at the specified time
    Page.Showobject[Listbox1]
    ListBoxObject[ListBox1].Add [Start, "%Files%"]
    -
    = Derek
    ["All glory comes from daring to begin" - fortune cookie]

    Comment

    • TJ_Tigger
      Indigo Rose Customer
      • Sep 2002
      • 3159

      #3
      Re: Looking for suggestions

      It does not have to be populated before it was hidden. Trying to do too much on page show rather than when the button is clicked to actually show the list box. I have been trying to think of different ways to get around this issue and none of them the easy way.

      Thanks Derek.
      TJ-Tigger
      "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
      "Draco dormiens nunquam titillandus."
      Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

      Comment

      • Worm
        Indigo Rose Customer
        • Jul 2002
        • 3971

        #4
        Re: Looking for suggestions

        I don't know if I achieved what you were looking for, but this will grab all the MP3s in the %SrcDir%\MP3 Folder and add them to the ListBox. When you want to add more MP3s, simply drop them in the %SrcDir%\MP3 folder and you're done.

        You can grab it here.

        Comment

        • TJ_Tigger
          Indigo Rose Customer
          • Sep 2002
          • 3159

          #5
          Re: Looking for suggestions

          Thanks Worm.

          I was able to do a search and find the .mp3s and add it to a list box, I was just trying to do it on Page.show before the list box was hidden and occasionally I would get an error.

          Following Dereks suggestion above, no worries mate.

          Tigger
          TJ-Tigger
          "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
          "Draco dormiens nunquam titillandus."
          Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

          Comment

          • Worm
            Indigo Rose Customer
            • Jul 2002
            • 3971

            #6
            Re: Looking for suggestions

            Okey-Dokey!

            I was getting an error too when populating the Listbox after showing it. I wish you could work with the object when it is NOT visible.

            Are you using the whole path and filename as the listbox data? The sample I made has a nice little twist to it that grabs the filename, truncates the extension and uses it for the list box data, while using the path and filename for the itemdata.

            Comment

            • TJ_Tigger
              Indigo Rose Customer
              • Sep 2002
              • 3159

              #7
              Re: Looking for suggestions

              Here is what I am doing in the project. The MP3s are designed to play automatically in the background upon runtime of the project. Here are the steps I take to accomplish that.

              On Project Initialization (requires that you have a global list named "playlist" in your project.

              %SongList% = File.Search ("*.mp3",CustomPaths)
              GlobalList(playlist),Add(Beginning,"%SongList%")

              On Page Initialization I have a script that will only load a song randomly once. I did this so the background music would not reset everytime the page was reloaded but would continue to play.

              <font color=blue>IF (!%Visit%)</font color=blue>
              %numitems% = GlobalList (playlist), GetProperty ("Item Count")
              %MaxIndex% = Evaluate (%NumItems% - 1)
              %RndValue% = Variable.SetRandomValue (Number, 0, %MaxIndex%)
              GlobalList(playlist), SetPosition (%RndValue%)
              %FullPath% = GlobalList(playlist), GetItem (Current)
              MP3.Load (""FullPath%")
              MP3.Play
              %Visit% = Evaluate (TRUE)
              <font color=blue>END IF </font color=blue>

              Then on Page.Show, I would try to have it populate a ListBox and then hide it. It would work occasionally but sometimes it would fail. So I followed Dereks suggestion and the Button that I have on the page that shows the list box also populates the list box as follows.

              <font color=blue>IF (%ListBox% = "OFF")</font color=blue>
              Page.ShowObject ("ListBox1")
              <font color=blue>IF (!%PopulateLB%)</font color=blue>
              %Files% = GlobalList9playlist0,GetItem (All)
              ListBoxObject(ListBox1),AddFiles (Start, "%Files%")
              %PopulateLB% = Evaluate (TRUE)
              <font color=blue>END IF</font color=blue>
              %ListBox% = "ON"
              <font color=blue>ELSE</font color=blue>
              Page.HideObject ("ListBox1")
              %ListBox% = "OFF"
              <font color=blue>END IF</font color=blue>

              On Page.Show I hide ListBox1 as well as populate the variable %ListBox% = "OFF" for the toggle function of the ListBox button described above.

              Aside from those commands, I have a play, stop, info, and volume button. In the MP3 player, ON.SONG.END event, I run through the get random song routine again, load it and play. And the commands for the list box itself. I have it set to On.Selection.Change event to get, load and play the MP3 then Hide itself.

              Here is a project with all of the above. It just needs a folder in the distribution folder called mp3 with mp3s in it to work right.

              get it here
              TJ-Tigger
              "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
              "Draco dormiens nunquam titillandus."
              Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

              Comment

              • Worm
                Indigo Rose Customer
                • Jul 2002
                • 3971

                #8
                Re: Looking for suggestions

                Thanks for sharing. Sorry I didn't catch the actual reason for the post. Oh well...

                Comment

                Working...
                X