PDA

View Full Version : Easy Newbie Question



ghobii
04-03-2003, 08:08 AM
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.

Worm
04-03-2003, 08:32 AM
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
----------------------------------

ghobii
04-03-2003, 08:48 AM
Cool! I love this program.

ghobii
04-03-2003, 09:04 AM
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?

Worm
04-03-2003, 09:19 AM
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

ghobii
04-03-2003, 09:59 AM
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.

Worm
04-03-2003, 10:04 AM
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

ghobii
04-03-2003, 10:44 AM
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>

Worm
04-03-2003, 10:58 AM
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.

ghobii
04-03-2003, 11:10 AM
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?

Worm
04-03-2003, 12:41 PM
I'm much better at doing than explaining. Mostly because when I DO it, I realize what I think will work won't /ubbthreads/images/icons/smile.gif

Here is a sample app. (http://www.warmuskerken.com/ams/playvideo.zip)

ghobii
04-03-2003, 01:37 PM
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?

Worm
04-03-2003, 01:42 PM
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.

ghobii
04-03-2003, 01:53 PM
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.

Worm
04-03-2003, 02:03 PM
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.

ghobii
04-03-2003, 02:34 PM
I'm getting that media player in the wrong state at the end of the last video. Can't seem to figure out what is causing it.
The way I thought of doing this works, but involves significantly more typing. This involves typing in the list of videos I want to play for each button to define %videos%. Works perfect, but it's alot more work with the number of videos I have. Your method would be much easier.

Worm
04-03-2003, 02:38 PM
Remember that a delimited list starts out at zero. So if you want to play 5 videos, the %LastVideo% would be set to 4

0, 1, 2, 3, 4 = 5 videos

ghobii
04-03-2003, 02:55 PM
Yeah, it also helps to define the 2 extra videos you added, into the %Videos% definition. DOH!
Thanks for your patience. I think I now have all the tools to finish this project. I think...

Worm
04-03-2003, 02:56 PM
Probably wouldn't have taken so long if I'd have steered you in the right direction in the first place.

G'Luck

ghobii
04-04-2003, 11:19 AM
One more issue...the client wanted the ability to play the videos full screen. No problem, made a button with the set full screen property. What I want to do is at the end of one of the sequence of videos, have it automatically go back to windowed mode. I tried adding this statement to the current script we put in the endofstream after the endif-
<IR_ACTIONS_LIST>
<Action name="IF">
<Type>200</Type>
<Function>1</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Condition>%Video% = %LastVideo%</Condition>
</Action>
<Action name="Set Full Screen">
<Type>138</Type>
<Function>0</Function>
<DTIndentLevel>1</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<ObjectName>MediaPlayer1</ObjectName>
<FullScreen>False</FullScreen>
</Action>
</IR_ACTIONS_LIST>

But for some reasonit runs at the end of each video.

ghobii
04-04-2003, 12:03 PM
Ahh, my fault. It should have been
%SelectedVideo% = %LastVideo%
Now it works. Although it does momentarily go back to windowed mode while loading the next video. Any ideas?