View Full Version : Help with position: URGENT!
playmenow
03-10-2006, 05:17 AM
I have a BIG problem. I made another slider and use it to show the position and to seek. The only problem is with this script:
Page > OnTimer
-- get the position and set it
if Playing == true then
Pos = MediaPlayer.GetCurrentPos("Media");
Slider.SetSliderPos("Position", Pos);
end
And the slider:
-- set the position
MediaPlayer.Seek("Media", SEEK_SPECIFIC, e_Pos);
I think you can imagine what it does, as the timer is activated when it starts playing the file...anyway, here's the project: (attachement)
Desmond
03-10-2006, 10:13 AM
Have you set the range of the slider to the media's length?
I took a quick look at it PMN. I can't devote a lot of time to it but the Slider Range that is being set in the Play function isn't setting the slider max to the correct value, its setting it to zero. I moved the last two lines that set the range into the Media PLayers On PLay event, and it worked for showing the position. However, the On Timer event is stopping you from being able to set the seek position on the media player... You're going to have to come up with a way to kill the timer while the mouse button is down on your slider.
Desmond
03-10-2006, 10:24 AM
Maybe check out the page's 'On Mouse Button' event. Stop the timer when the left button is down, start it when it goes up.
Give 'er a shot anyhow, it *may* work.
Desmond.
There is a function in the Slider Framework named IsInRect that you could use to determine if your mouse pointer is inside the slider too. That way you'd only stop the timer if the mouse was down on the slider.
playmenow
03-10-2006, 11:17 AM
how to use slider framework?
You don't have to use it. I think it'd look betterm, but that's just me. All I was saying is that you could use that particular function to help you out.
Here's a link to the Slider Framework
http://www.indigorose.com/forums/showthread.php?t=15195
playmenow
03-10-2006, 11:31 AM
...sorry...it doesn't set the position!!! i made maybe some typos
Hmmm.... thought I already did the Slider Framework for you. :)
It's really simple to use.
Here's a simple step by step:
Start a new project. (or grab the empty one attached here and skip step 1)
1. Cut and Paste the code that is in the posting
2. Create two Images (preferably PNG for transparency), one for your slider background and one for your knob
3. add the images to AMS.
4. Name the background image: hslider_Position
5. Name the knob: hknob_Position
6. Move them into position on your page.
7. That's it.
From there you simply use the Custom event like you would the Slider Plugins.
playmenow
03-10-2006, 12:01 PM
I won't use the slider framework....it kills my CPU...here's what I have so far with the standard sliders:
playmenow
03-10-2006, 12:02 PM
I won't use the slider framework....it kills my CPU...here's what I have so far with the standard sliders: (sorry for doublepost...i forgot to upload the file)
it kills my CPU
When I use it, it takes my CPU to 15%'ish... what could you possibly be doing that is so processor intensive?
playmenow
03-10-2006, 12:11 PM
Good. I have a tip for you: have you heard of "elseif" ? It saves you from typing an "end" :)
It works! Worm, wanna a beer?
Dude!
I don't think elseif would save you from using an end as you still need to close out your ifs. Even if I'm wrong and it does save you from typing an end, it's bad practice IMO.
I'll try to sneak a couple elseif's into my code if thats what it takes to impress. :yes
Nothing...this is a P3 600 Mhz CPU (but it works like 2Ghz!!!!!!!!:eek:)
If it chokes on the Slider Framework... Obviously.... it doesn't ;)
playmenow
03-10-2006, 12:50 PM
erm....you can turn:
if something == true then
--do something
else if bhjhi == 65 then
--another
end
end
in to:
if something == true then
--do something
elseif bhjhi == 65 then
--another
end
Well... logic comes into play here too. It all depends on what you need to happen. In your case/use of if/elseif unless your variable something is false, then the other variable bhjhi will never be evaluated. Maybe that's what you want, maybe not. Maybe you need to perform actions if something is true, then perform different actions if bhjhi equals 65 in which case the elseif scenario isn't the tool for the job.
Besides, if you'd have taken 1/10th of the time I've now taken to help you to "actually" look at some of the code I've used in the postings, you'd have seen several elseif's in my code. Now don't get me wrong here, I can probably learn a lot from you, and I truly hope to. After all, that is the true spirit of this forum and why I keep coming back :yes
Nothing...this is a P3 600 Mhz CPU (but it works like 2Ghz!!!!!!!!)
ummm.. That is over triple the speed overclocked?? Maybe its the 240v European plugs or something because that seems pretty extreme.
Adam.
Intrigued
03-10-2006, 04:13 PM
Worm, you are still a professional programmer by day right?
;)
What's your motto? VB or bust?
Worm'inator is a paid, professional programmer and though he learns from us "underlings" by some off chance of luck on our part, he has shown to most of us he can "get-er-dun" like just about no one else in the I.R. forums.
:yes
... I can probably learn a lot from you ...
Sure.... kinda like kids learn from an ant farm... until they get bored and shake it all up! Please don't shake the forum Worm...
Dermot
03-11-2006, 01:43 AM
if something == true then
--do something
elseif bhjhi == 65 then
--another
end
That would not make sense in most situations because you are evaluating two different variables. elseif is most commonly used when evaluating the same variable.
If x == 1 then
do something
elseif x == 2
do something else
end
If you need to evaluate a second variable based on the value of the first you would nest another if statement instead of using elseif.
If x == 1 then
if y = 1 then
do something
elseif y = 2 then
do something else
end
end
Like Worm said, it all depends on what you are trying to achieve and there will always be exceptions.
Worm'inator is a paid, professional programmer and though he learns from us "underlings" by some off chance of luck on our part, he has shown to most of us he can "get-er-dun" like just about no one else in the I.R. forums.
I will second that. :yes
Corey
03-11-2006, 02:02 AM
I'll third it. Worm has earned the respect and admiration of everyone here as well as the entire staff of Indigo Rose, I would certain examine anything he writes *very* carefully before concluding it's inefficient.
Besides getting Brett onto a skateboard one of my core life goals is to finally hear an MP3 of Worm playing guitar. Come to think of it I wouldn't kick an MP3 of Brett playing guitar out of bed for eating crackers either. :D
playmenow
03-12-2006, 07:04 AM
Hey Worm, I removed more from the code you put, but I still can't blow a bug:
function Position()
-- set the position
if LeftDown == true then
Page.StopTimer();
MediaPlayer.Seek("Media", SEEK_SPECIFIC, e_Pos);
Page.StartTimer(1000);
end
end
Will seek to 0 seconds...not good, as I want to submit PlayMeNow to softpedia.com. What should I do:huh I made the timer not to change the position if I press the left mause button.
e_Pos is not a global variable, it's only defined within the event. I'd guess you probably need to pass e_Pos from the slider into your function.
in the slider
Position(e_Pos);
The function would be
function Position(e_Pos)
-- set the position
if LeftDown == true then
Page.StopTimer();
MediaPlayer.Seek("Media", SEEK_SPECIFIC, e_Pos);
Page.StartTimer(1000);
end
end
playmenow
03-12-2006, 08:31 AM
Thanks Worm! to be sure, I placed it on the clider On Position Change (without the function..)
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.