PDA

View Full Version : Attaching the Slider plug-in to my video


allenz
10-02-2004, 08:48 PM
Hi again.

Okay, I got my page with a panel on it and inside the panel is my video object minus the player control panel as I need my own customized controls.

Got all the buttons set and now on to the slider. So how do I connect the slider to my video so the slider moves in relation to the video?

Can't seem to find any help on this one. I was looking at the script actions but don't quite understand them yet. I'm working on it!

Thanks
Allen

Intrigued
10-02-2004, 10:00 PM
allenz, I updated the VideoSeek .apz file I shared with you a while back. It may be what you need. You can find the code in the Page1's On Timer event tab.

VideoSeek (http://www.indigorose.com/forums/showpost.php?p=38567&postcount=6) (link is in the thread)

Notice how the timing is off a tad though? Well, try it out and see what you can make of it. Good Luck!

Sincerely,

Neill Karl
10-03-2004, 01:21 AM
I just got through putting the slider in my video. I used the on timer function on the page I put it on, then on every timer tick, go get my current video frame, do some math on it to convert it to a desired slider position, then set the slider position. Looks like this:

-- First I get my current video frame - I'm using Flash, so it looks like this...
curframe = Flash.GetFlashVariable("Flash2", "_currentframe");
-- My slider is 1000 units long, totalframes is the total frames in my video
newpos = 1000*(curframe/totalframes)
-- Then move the slider
Slider.SetSliderPos("Time Slider", newpos);

Hope it helps!

allenz
10-04-2004, 04:53 AM
Thanks. I'll try out both the suggestions. Haven't got ino the timer yet.

Allen

allenz
10-04-2004, 06:56 PM
-- First I get my current video frame - I'm using Flash, so it looks like this...
curframe = Flash.GetFlashVariable("Flash2", "_currentframe");
-- My slider is 1000 units long, totalframes is the total frames in my video
newpos = 1000*(curframe/totalframes)
-- Then move the slider
Slider.SetSliderPos("Time Slider", newpos);

Hope it helps!

Neill Karl, question. At the "curframe" what do I put? My video is "video1.mpg". I put that in but got an error msg. I also put my video title inside the () replacing "Flash2'. this video is 465 frames so I replaced your 1000 with 465

I got lost somewhere.
Allen :huh

allenz
10-04-2004, 07:08 PM
Intrigued
I tried your updated project file. There isn't a pause button so I couldn't see if the slider actually would control the video as my sample video is only 15 seconds long. I tried it and it didn't seem to want to control the video. Also I see a large slider on the player itself. I wanted to get away from that.

Actually I'd like to be able to set the slider to say Mile Posts on a Railroad so if someone moved the slider to MP 4 for example, it would bring the video there and show a frame until they clicked the play button.


I think Karl's script seems to be what I want but I need to know how to change it from his Flash file to my video file. See my reply to him above.
Allen

allenz
10-04-2004, 07:15 PM
Karl
When previewing the page, and I click on the slider the error message says;
OnPosChange, Line2: attempt to index global 'video1'(a nil value).

Can you help on this?
Thanks
Allen

Intrigued
10-04-2004, 08:33 PM
allenz, try the .apz file again. I have added in some code in the appropriate areas and comments where clarification was, I thought, needed.

Let me know how this works...

ps. I just unchecked the slider checkbox option in the page's settings dialog box to rid the video of that feature.

ps. I did the Play button... I'll let you practice and finish (if you use this version) up on the chapter buttons.

Sincerely,

allenz
10-05-2004, 06:34 AM
I just can't find it. Opened your latest apz file, put my own video in.

Double clicked on page 1. Only script I can find is "on finish" a script about a btn_state.

Clicked on the slider (yours not the one on the player) and can find no code. Clicked on the slider text and see no script code.

Noticed also that the script code for the 'loop' check box is attached to the "loop" text and not the button. Why is that? I would have thought that button code would be attached to a button and not the text label.

Now the slider on the video player works as I'd like but I can't control or move the video using your added slider. Although the added slider does work by itself. If I try to move the added slider, it jumps back to the current video position.

Sorry intrigued, I just don't understand your example.
I want to try Karl's script above as soon as I can figure out how replace his flash reference with my video information.

Allen

Intrigued
10-05-2004, 09:00 AM
I understand allenz... it takes practice... best of luck!

Sincerely,

Neill Karl
10-05-2004, 09:29 AM
The GetFlashVariable that I was using to get my current frame is unique to working with flash. To get the current frame of a video object like your movie, use Video.GetCurrentPos to find out the current time into the movie, and then use Video.GetLength to find out the total length. Then you'll have what you need to calculate your desired slider position. It will look something like this:

slider_range=Slider.GetRange("YourSliderObjectName"
curtime = Video.GetCurrentPos("YourVideoObjectName");
totaltime=Video.GetLength("YourVideoObjectName");
newpos = slider_range*(curtime/totaltime)
newpos=Math.Round(newpos,0)
Slider.SetSliderPos("YourSliderObjectName", newpos);

Hope it helps!

Neill

allenz
10-05-2004, 09:43 AM
Neill
Oh! Okay and thanks. Now it makes more sense. I'm using my small network computer to check this now as my main computer is processing a video. As soon as it's finished, I will open AMS and change the script.

Will get back to you later today and let you know if it worked.

Thanks for clarifying this for me.
Allen

allenz
10-08-2004, 05:03 AM
Karl
Where do put that script? On the slider or the page? I put it on the slider but it doesn't seem to work. It debug's fine and the project previews okay but the slider just doesn't work. However if I put my mouse on the slider and try to move it, I get an error message in the preview.



Allen

Neill Karl
10-12-2004, 08:54 AM
Allen,

Put the slider stuff in the 'on timer' section of the page actions. Then, set up the timer in the 'on show' section. Ticks every tenth of a second will keep it looking smooth. So, in your 'on show' section, put:

Page.StartTimer(100);

Now, your code in the 'on timer' section will get executed every tenth of a second while the page is displayed. The slider will keep moving to keep up with the movie.

Good luck!

Neill