loop sound actionscript Flash - arrays

i want to know if anyone can help me with actionscript in Flash.
i want to have some different buttons and play different sound loops when i click in the button, but every loop has to start when the other finished because of the music melody. can anyone help me?
Thank you
Teresa

By using SoundChannel class in AS3, you can get addEventListener - Event.SOUND_COMPLETE, which will notify you about the sound complete and then you can play the next sound

Well i am assuming you want to play the sound associated with the last button pressed and not play many sounds together.
So you have a global sound variable which you change on button press
var sound:Sound=new Sound(new URLRequest("music.mp3"));
var soundChannel:SoundChannel=new SoundChannel();
soundChannel=sound.play();
soundChannel.addEventListener(Event.SOUND_COMPLETE,loop_Sound);
function loop_Sound(e:Event){
soundChannel=sound.play();
//I know you don't need to add the listener again to the sound channel
//but this is something i just do
soundChannel.addEventListener(Event.SOUND_COMPLETE,loop_Sound);
}
//call this function when the button is pressed
//you could name the button name as the sound file's name
//and use e.currenttarget.name or something
function change_Sound(e:MouseEvent){
sound=new Sound(new URLRequest("music2.mp3"));
}
This would load the sound when the button is pressed but play it only when your current sound finishes playing and if the button is not pressed while it is playing it would loop the current sound .Best Of Luck!!

Related

How to get duration of Youtube video without playing the video in Reactjs

I am a newbie in ReactJS and I badly need some help.
So I have a video catalog that only shows the thumbnails of the videos with label and overlay duration. Before I was using React-Player by Pete Cook but I don't want that my video player has share, like and watch later buttons so I decided to not use it and use video-player instead. I just use Image tag for showing thumbnail and I will just pass the Youtube link to the video player if the image is clicked.
Now my problem is that I am having a hard time in getting the video duration. When I was still using React-Player, I can get it after clicking play button (not the result that I want but at least I was able to get the duration). Any solution for this?
Your problem is you're providing a Youtube URL to the video-player library's Player Component which clearly doesn't support it as mentioned here.
I even tried it you'll get no duration value nor the video will be played.
However, if you changed your Youtube link to for example this one https://www.w3schools.com/html/movie.mp4
You'll find that everything is working perfectly and you can get the duration state from the Player's states without even playing the video.
const { player } = this.player.getState();
console.log(player.duration);
I added these two lines to the a method called changeSource mentioned here under Examples title.

Button does not work on some mobile devices (eg iPhone6, Androids)

this is my first question here and I was adviced to place this topic here.
I got a responsive website based on the AURA (PI-)theme. For the xs2 breakpoint I do show another slideshow on the homepage, where I have placed an button as call to action (other button type didn't work either)
On older smartphones like iPhone4 and 5 it is working. But on newer device it ain't.
Please take a look onto this test-page.
You can also check within chrome browser emulating such a device. There the click on the "Explore"-button doesn't work either.
Any help is gladly welcome and I appriciate it very much.
Thank you!
It's quite simple. You got a slideshow with a swipe handler which probably sets a preventDefault for swipe and click/tap. If I try to click it on a test device (android 4), it won't work either. But it does work if i hold it down and then press open. So it's not about the z-index (common error) but about the preventDefault. This means you would have to assign the link to the button/s in the slideshow with javascript.
EDIT:
To assign a link to an element using javascript (just javascript, no jquery or any other library), just put something like that into a script tag or javascript file:
document.getElementById("ID-of-your-button").addEventListener("click", function(){window.location.href = "http://link-desti.nation"});
and that should work fine. If there is another problem with it, just write a comment below please. I will reply on it as soon as possible.
P.S.: Sorry for the late edit, I was having hilariously much work on a "do immediately" level the last days.

videoangular--How to have multiple video players in one screen?

Hi so Im using this angularjs framework "videogular" and have no problem creating a single player, but I dont know how to create multiple players in one screen since apparently each player requires a controller
sample code here:
http://codepen.io/2fdevs/pen/KmDIE
Each player needs a different config file but not a different controller.
Maybe this other answer could be useful:
stop other video that is playing in background on play the new one

Recording a video with audio using GPUImageMovieWriter without jerkiness at start and end of recording?

I am using GPUImage framework to record multiple videos one after other in close intervals with having various filters enabled in real time using GPUImageVideoCamera and GPUImageMovieWriter.
When I record the video, video starts with a jerk(freeze for half a seconds) and ends with a jerk also. I know the reason behind this are the statements in which I pass the movieWriter object to VideoCamera's audioEncodingtarget.
So In my case when I record multiple videos one after other(with different objects of GPUImageMovieWriter), the video preview view freezes at start and end of each recording.
If I remove the audio encoding target statement, conditions improves significantly but of course I don't get the audio.
Currently I am using a AVAudioRecorder while recording to save audio tracks but I believe this is not a ideal work around.
Is there any way to solve this problem.
-- I looked at the RosyWriter example by Apple, their app work almost similarly but smoothly at almost constant 30 fps. I tried to use the RosyWriter code(after removing the code that add purple effect) to save the required videos while showing GPUImageVideoCamera's filtered view to user but in vain. When applied unmodified rosywriter code just records two videos and rest video fails. I also tried to pass in the rosywriter code the capture session from GPUImageVideoCamera but only gets videos with black frames and no audio.
Please help on how can I can record GPUImage filtered videos with audio without this jerkiness. Thanks in advance
I faced the same issue and here is my workaround.
As you pointed out, this problem happened because setAudioEncodingTarget method internally calls addAudioInputsAndOutputs to set audio in/output to the capture session.
To avoid this issue, I created justSetAudioEncodingTarget method for VideoCamera as below,
(on GPUImageVideoCamera.m)
// just set
-(void)justSetAudioEncodingTarget:(GPUImageMovieWriter*)newValue {
if( newValue == nil ) {
return;
}
addedAudioInputsDueToEncodingTarget = YES;
[super setAudioEncodingTarget:newValue];
}
The following steps is my scenario and I checked out it smoothly worked.
Called VideoCamera's addAudioInputsAndOutputs after the VideoCamera was created.
This is not right before starting the recording. :)
Set MovieWriter to the VideoCamera by justSetAudioEncodingTarget that I made above.

AVPlayer + loop + background

I need to:
play a sound
loop
continue to play in background
All works fine with AVAudioPlayer, but now I have to use AVPlayer to play also music songs from the iPod library. But there is a big problem: AVPlayer has no numberOfLoops property like in AVAudioPlayer.
Ok, you can register a notification to the NSNotificationCenter for AVPlayerItemDidPlayToEndTimeNotification (or you can also use the addBoundaryTimeObserverForTimes method with specified times equal to the song duration) to be notified when a song has played to the end.
But this works only if the app is in the foreground, in the background the song continues to play, but stops at the end.
The notification is received also in the background (checked with a NSLog), but the selector's code:
AVPlayerItem *playerItem = [notification object];
[playerItem seekToTime:kCMTimeZero];
...has no effect, the song doesn't loop.
Any suggestions?
The problem you have is the second the player does a seektotime your app looks like it's done playing audio, and so it's thrown on the bonfire. :)
I spent days creating this workaround:
Add "App plays audio" to "Required background mode" in info.plist
Create another AVplayer that plays a one second mp3 file at 0.00000001f rate (silentMp3Player.rate=0.0000001f) which starts when your app enters background and stops when it re-enters foreground.
Try to add this code:
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
try AVAudioSession.sharedInstance().setActive(true)

Resources