Announcement

Collapse
No announcement yet.

Easy Newbie Question

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

  • Easy Newbie Question

    I have a bunch of buttons that start videos but before I start them I want to jump to a different page where I have the media player object. How do I have all those buttons jump to that same page but play a different video. I know I can do it by just copying the page and loading a different video on each page. But does this make the project larger or slower? I would like to learn the correct efficient way of doing things before I develop bad habits.

  • #2
    Re: Easy Newbie Question

    Set a variable to the path and filename of the video you want to run.

    Events would go like this:

    User Clicks Button
    Variable is set to the selected videos path and filename
    Jump to Video Page
    On Show Load video from variable

    --Click Event--
    %Video% = "%SrcDir%\MyVideo.mpg"
    Page.Jump ("PageThatPlaysVideo")
    ----------------------------------

    --On Show Event---
    MediaPlayerObject[MediaPlayer].Load ("%Video%")
    MediaPlayerObject[%MediaPlayer%].Play
    ----------------------------------

    Comment


    • #3
      Re: Easy Newbie Question

      Cool! I love this program.

      Comment


      • #4
        Re: Easy Newbie Question

        If I wanted the button to play multiple videos back to back could I just put them all in the variable? How would I seperate them? Or would I somehow use the list object?

        Comment


        • #5
          Re: Easy Newbie Question

          When you set the variable, seperate the videos with a delimiter like this:

          %Videos% = "%SrcDir%\Video1.mpg;;%SrcDir%\Video2.mpg;;%SrcDir %\Video3.mpg"

          Then in the On Show:
          // Get the number of videos to be played
          %NumVideos% = String.CountDelimitedStrings ("%Videos%", ";;")
          // Set a counter variable to zero
          %Ctr% = "0"
          // Set up loop to play the videos
          WHILE (%Ctr% < %NumVideos%)
          // Get the video from the delimited string
          %VideoToPlay% = String.GetDelimitedString ("%Videos%", ";;", %Ctr%)
          MediaPlayerObject[MediaPlayer].Load ("%VideoToPlay%")
          MediaPlayerObject[%MediaPlayer%].Play
          // Increment Counter to get the next video in the sequence
          %Ctr% = Evaluate (%Ctr% + 1)
          END WHILE

          Comment


          • #6
            Re: Easy Newbie Question

            Most of this makes sense, but how exactly do I add that "Evaluate" line? I'm trying to do it as a "set variable" but am getting the error- "Missing operator before open parenthesis" when I try to create the value- Evaluate(%Ctr%+1)
            I assume I am not understanding the usage here.

            Comment


            • #7
              Re: Easy Newbie Question

              You're doing it right. When you are setting the variable, look to the bottom left of the text box and you'll see a checkbox that lets you evaluate. In the textbox, put the arithmetic

              %Ctr% + 1

              Comment


              • #8
                Re: Easy Newbie Question

                Yeah, the problem was I was typing in the word "Evaluate" as part of the expression. Problem now is, it doesn't work. I get the error that mediaplayer isn't in the correct state and when I close the error box it plays the LAST video in the sequence. Do I somehow have to tell it to wait for each video to end before it does the evaluate? Here is the script-


                - <IR_ACTIONS_LIST>
                - <Action name="Count Delimited Strings">
                <Type>63</Type>
                <Function>0</Function>
                <DTIndentLevel>0</DTIndentLevel>
                <Enabled>1</Enabled>
                - <ErrorHandling>
                <UserNotificationMode>2</UserNotificationMode>
                <CustomErrorMessage />
                <OnErrorAction>0</OnErrorAction>
                <JumpToLabel />
                </ErrorHandling>
                <Variable>%NumVideos%</Variable>
                <Source>%Videos%</Source>
                <Delimiter>;;</Delimiter>
                </Action>
                - <Action name="Set Value">
                <Type>6</Type>
                <Function>0</Function>
                <DTIndentLevel>0</DTIndentLevel>
                <Enabled>1</Enabled>
                - <ErrorHandling>
                <UserNotificationMode>2</UserNotificationMode>
                <CustomErrorMessage />
                <OnErrorAction>0</OnErrorAction>
                <JumpToLabel />
                </ErrorHandling>
                <Variable>%Ctr%</Variable>
                <Value>0</Value>
                <Evaluate>0</Evaluate>
                </Action>
                - <Action name="WHILE">
                <Type>204</Type>
                <Function>1</Function>
                <DTIndentLevel>0</DTIndentLevel>
                <Enabled>1</Enabled>
                - <ErrorHandling>
                <UserNotificationMode>2</UserNotificationMode>
                <CustomErrorMessage />
                <OnErrorAction>0</OnErrorAction>
                <JumpToLabel />
                </ErrorHandling>
                <Condition>%Ctr% < %NumVideos%</Condition>
                </Action>
                - <Action name="Get Delimited String">
                <Type>64</Type>
                <Function>0</Function>
                <DTIndentLevel>0</DTIndentLevel>
                <Enabled>1</Enabled>
                - <ErrorHandling>
                <UserNotificationMode>2</UserNotificationMode>
                <CustomErrorMessage />
                <OnErrorAction>0</OnErrorAction>
                <JumpToLabel />
                </ErrorHandling>
                <Variable>%VideoToPlay%</Variable>
                <Source>%Videos%</Source>
                <Delimiter>;;</Delimiter>
                <ItemIndex>%Ctr%</ItemIndex>
                </Action>
                - <Action name="Load">
                <Type>90</Type>
                <Function>0</Function>
                <DTIndentLevel>0</DTIndentLevel>
                <Enabled>1</Enabled>
                - <ErrorHandling>
                <UserNotificationMode>2</UserNotificationMode>
                <CustomErrorMessage />
                <OnErrorAction>0</OnErrorAction>
                <JumpToLabel />
                </ErrorHandling>
                <ObjectName>MediaPlayer1</ObjectName>
                <Document>%VideoToPlay%</Document>
                </Action>
                - <Action name="Play">
                <Type>47</Type>
                <Function>0</Function>
                <DTIndentLevel>0</DTIndentLevel>
                <Enabled>1</Enabled>
                - <ErrorHandling>
                <UserNotificationMode>2</UserNotificationMode>
                <CustomErrorMessage />
                <OnErrorAction>0</OnErrorAction>
                <JumpToLabel />
                </ErrorHandling>
                <MediaPlayerObjectName>MediaPlayer1</MediaPlayerObjectName>
                </Action>
                - <Action name="Set Value">
                <Type>6</Type>
                <Function>0</Function>
                <DTIndentLevel>0</DTIndentLevel>
                <Enabled>1</Enabled>
                - <ErrorHandling>
                <UserNotificationMode>2</UserNotificationMode>
                <CustomErrorMessage />
                <OnErrorAction>0</OnErrorAction>
                <JumpToLabel />
                </ErrorHandling>
                <Variable>%Ctr%</Variable>
                <Value>%Ctr% + 1</Value>
                <Evaluate>1</Evaluate>
                </Action>
                - <Action name="END WHILE">
                <Type>205</Type>
                <Function>1</Function>
                <DTIndentLevel>0</DTIndentLevel>
                <Enabled>1</Enabled>
                - <ErrorHandling>
                <UserNotificationMode>2</UserNotificationMode>
                <CustomErrorMessage />
                <OnErrorAction>0</OnErrorAction>
                <JumpToLabel />
                </ErrorHandling>
                </Action>
                </IR_ACTIONS_LIST>

                Comment


                • #9
                  Re: Easy Newbie Question

                  Doh!

                  I didn't even think of that. You'll have to set the loop up in the Media Player Objects On Stream End instead of the On Show. That way it'll wait for the video to finish before trying to load the next one.

                  Comment


                  • #10
                    Re: Easy Newbie Question

                    I moved that whole script to the "onend stream" of the media player object. Now I get the same error but no videos play. I still have your original script, the one that played one video, in the page-on show. Does something have to be done different there?

                    Comment


                    • #11
                      Re: Easy Newbie Question

                      I'm much better at doing than explaining. Mostly because when I DO it, I realize what I think will work won't [img]/ubbthreads/images/icons/smile.gif[/img]

                      Here is a sample app.

                      Comment


                      • #12
                        Re: Easy Newbie Question

                        Ok, I mostly see how that works. But what if I have 5 videos and I only want to play 2,3 and 4? You define %Videos% in the onshow of page one- could you instead define that list per button? Listing just the videos you want.? Or am I misunderstanding how it works?

                        Comment


                        • #13
                          Re: Easy Newbie Question

                          As long as you set the %SelectedVideo% variable to the starting point in the delimited string when the user clicks the video they want to watch, it will start from that point and play the rest of the videos in sequence.

                          Comment


                          • #14
                            Re: Easy Newbie Question

                            Right, I understand how to start at any point in the list. I don't understand how I can STOP somewhere other then the end. In reality I have 30 videos that I need to show in groups- 1-7, 8-12, 13-18 etc, as well as be able to play any of them individually.

                            You have been a great help, but keep in mind I'm an artist, not a programmer. This stuff is new to me.

                            Comment


                            • #15
                              Re: Easy Newbie Question

                              Ahhh! In that case, set another variable when they click the video to play.

                              %LastVideo% = "5"

                              Then in the On Stream End change the If statement

                              IF (%SelectedVideo% <= %LastVideo%)

                              This would play from whatever you selected up through video 5.

                              Comment

                              Working...
                              X
                              😀
                              🥰
                              🤢
                              😎
                              😡
                              👍
                              👎