Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sound.stop() and Sound.position() #340

Closed
ousia opened this issue Jan 18, 2020 · 9 comments · Fixed by #5482
Closed

Sound.stop() and Sound.position() #340

ousia opened this issue Jan 18, 2020 · 9 comments · Fixed by #5482
Labels
A-audio Area: Audio

Comments

@ousia
Copy link
Contributor

ousia commented Jan 18, 2020

@Herschel,

the button for play/pause in https://randomfoo.net/oscon/2002/lessig/free_culture.swf can stop and start the sound again from the start, but not from the the position where it has been paused.

This is common code for the slide transition:

var i = 1;
var time = 0;
var timing = new Array();
timing[1] = 16.826;
timing[2] = 11.846;
timing[3] = 4.822;
timing[4] = 5.687;
timing[5] = 5.451;
timing[6] = 4.114;
// and so on...

var ptiming = 0;
var ntiming = timing[i];
if(time == "0") {
   time = getTimer() + timing[i] * 1000;
   Slides.gotoAndStop(i);
   lessig = new Sound();
   lessig.attachSound("Lessig_32.mp3");
   lessig.start();
}

The AS2 code for that button reads:

on(release) {
   if(!paused) {
      pause_start = getTimer();
      pause_offset = lessig.position;
      lessig.stop();
      stop();
      paused = 1;
   } else {
      pause_time = getTimer() - pause_start;
      lessig.start(pause_offset / 1000);
      time = time + pause_time;
      play();
      paused = 0;
   }
}

But the weird thing is that both the button to advance the slide:

on(release) {
   if(i < timing.length) {
      if(1 < i) {
         ptiming = ptiming + timing[i - 1];
      }
      i++;
      Slides.gotoAndStop(i);
      lessig.stop();
      lessig.start(ntiming);
      time = getTimer() + timing[i] * 1000;
      if(i < timing.length){
         ntiming = ntiming + timing[i];
      }
   }
}

and the button to go to the previous slide work perfectly fine:

on(release) {
   if(1 < i) {
      ntiming = ntiming - timing[i];
      i--;
      Slides.gotoAndStop(i);
      lessig.stop();
      lessig.start(ptiming);
      time = getTimer() + timing[i] * 1000;
      if(1 < i) {
         ptiming = ptiming - timing[i - 1];
      }
   }
}

I wonder whether it might be related to an issue with Sound.position() (I guess it has been implemented, but I really don’t know 😅).

@Herschel
Copy link
Member

Sound.position not implemented quite yet (cc #273).

@Herschel Herschel added the A-audio Area: Audio label Jan 18, 2020
@ousia
Copy link
Contributor Author

ousia commented Nov 15, 2020

@relrelb, it would be really great if you could implement Sound.position(), once #1445 is merged.

This would help to test other AS2 functionality on animations that depend on it.

Many thanks for your excellent work.

@ousia
Copy link
Contributor Author

ousia commented Dec 4, 2020

@relrelb I don’t know whether this could make sense (so, take it with a grain of salt).

Since #1445 may take time to be merged, I wonder if the Sound.position() could start before #1445 has been merged.

Just in case it might help. Many thanks for your excellent work.

@relrelb
Copy link
Contributor

relrelb commented Jan 28, 2021

Fixed by #2825?

@Herschel
Copy link
Member

Sound.stop is completely implemented in #2825, but haven't yet done Sound.position. I'll do this next.

@ousia
Copy link
Contributor Author

ousia commented Jan 28, 2021

Sound.stop is completely implemented in #2825, but haven't yet done Sound.position. I'll do this next.

This is really excellent news.

Many thanks for your excellent work

@ousia
Copy link
Contributor Author

ousia commented Feb 5, 2021

Looking forward Sound.position() being implemented.

Herschel referenced this issue in Herschel/ruffle Oct 17, 2021
Even though they were added in SWFv6, they will be available when
playing a v5 SWF in Flash Player 6 and higher.

See #340 for an example in the wild.
Herschel added a commit that referenced this issue Oct 17, 2021
Even though they were added in SWFv6, they will be available when
playing a v5 SWF in Flash Player 6 and higher.

See #340 for an example in the wild.
@Herschel
Copy link
Member

Thanks for the patience @ousia :-)

@ousia
Copy link
Contributor Author

ousia commented Oct 19, 2021

Many thanks for the fix, @Herschel.

Now I have another issues that I can follow better 😅.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-audio Area: Audio
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants