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

check? #99

Open
bootkitt opened this issue Feb 26, 2020 · 6 comments
Open

check? #99

bootkitt opened this issue Feb 26, 2020 · 6 comments
Assignees
Labels

Comments

@bootkitt
Copy link

function timelineFinished(destImg) {	
  ion.sound.play("pop_cork");
  $('#roulette-img' + destImg).css('box-shadow','rgb(18, 18, 19) 0px 3px 16px 3px');
  clearInterval(spin_sound);
  setTimeout(function() {   window.mainModal.showModal(); window.stateRulet = 1; }, 600);
}
@bootkitt
Copy link
Author

ion.sound.play("pop_cork") not working...

@IonDen
Copy link
Owner

IonDen commented Feb 27, 2020

Hi, today you can't expect an auto play to work properly. Too many restrictions to that.
You should first allow playing sounds in browser by letting user click on some button and play any sound and only then auto-playing will be unblock by the system.

@IonDen IonDen self-assigned this Feb 27, 2020
@bootkitt
Copy link
Author

bootkitt commented Feb 27, 2020

    function getRandomInt(min, max) {
      return Math.floor(Math.random() * (max - min + 1)) + min;
    }

    function getPositionOfWinner(winner) {
      var widthOfImg = $('#roulette-img1').width();
      var minDistanceToEdgeAllowed = 2;

      var desiredImg = $('#roulette-img' + winner.toString());

      var minPos = desiredImg.position().left + minDistanceToEdgeAllowed;
      var maxPos = desiredImg.position().left + widthOfImg - minDistanceToEdgeAllowed;

      return getRandomInt(minPos, maxPos);
    }
	
    function timelineFinished(destImg) {
      ion.sound.play("pop_cork"), $("#roulette-img" + destImg).css("box-shadow", "rgb(18, 18, 19) 0px 3px 16px 3px"), clearInterval(spin_sound), setTimeout(function() {
          window.mainModal.showModal(), window.stateRulet = 1		  
      }, 600)
    }        

    function rouletteSpin(destImg) {
      if (!destImg) destImg = 40;
      var tl = new TimelineMax({ 
        onComplete: timelineFinished, 
        onCompleteParams: [ destImg ] 
      }),
      rouletteImages = $('#roulette-images-list'),
      startLeft = rouletteImages.position().left;

      //Заготовка для звукового эффекта
      current = Math.floor(startLeft-197)
      spin_sound = setInterval(function()
      {
        if (current > Math.floor($('#roulette-images-list').position().left))
        {;
          ion.sound.play("snap");
          current -= 197;
          //console.log(current)
        }
      }, 20);
      //Заготовка для звукового эффекта


      tl.to(rouletteImages, 7, {x: getPositionOfWinner(destImg) * -1, ease:  Power1. easeInOut});
    }

where problem?

@IonDen
Copy link
Owner

IonDen commented Feb 27, 2020

Do you have online demo?

You should try this work around:

  1. Create a button on the page and name it "Allow sounds"
  2. Click on that button and play random sound
  3. Then try your code

@bootkitt
Copy link
Author

ion.sound.play("snap");
working...

function timelineFinished(destImg) {
ion.sound.play("pop_cork")

not working...

demo : https://oyunpaketim.club/

@IonDen
Copy link
Owner

IonDen commented Mar 3, 2020

How to reproduce? Site is big)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants