Hi,
I am experiencing an anomaly with uos_loopProcin() while working with the latest version of uos (v 2.0.1) running on linux 64-bit xfce. The procedure I associate with uos_loopProcin() runs while I play a sound for the first time, but the procedure is never called again if I loop and play the sound again after the first play. MyPlaySound procedure (called to start sound play) ------------ uos_CreatePlayer(playerindex); inputindex := uos_AddFromFile(playerindex, pchar(FileToPlay), -1, -1, -1); uos_InputSetPositionEnable(playerindex, inputindex, 1); uos_loopProcin(playerindex, inputindex, @MyPlayingNow); // run 'MyPlayingNow' procedure while sound plays uos_InputSetLevelEnable(playerindex, inputindex, 2); outputindex := uos_AddIntoDevOut(playerindex); uos_InputSetLevelArrayEnable(playerindex, inputindex, 2); uos_EndProc(playerindex, @MyPlayEnded); // // run 'MyPlayEnded' procedure after sound ends uos_inputseek(playerindex,inputindex,0); uos_Play(playerindex); MyNowPlaying procedure (should be called while sound is being played) ------------- // change caption of form while sound is being played Sound_VolumeLeft := uos_InputGetLevelLeft(playerindex, inputindex); Sound_VolumeRight := uos_InputGetLevelRight(playerindex, inputindex); form1.caption := 'Left Level: ' + floattostrf(Sound_VolumeLeft,fffixed,3,3) + ' - ' + 'Right Level: ' + floattostrf(Sound_VolumeRight,fffixed,3,3); MyPlayEnded procedure (called after sound play ends) ------------ showmessage('sound play has just ended'); // always activated when sound play ends; // activated also at end of each loop if // sound looping is being performed uos_inputseek(playerindex,inputindex,0); if (noloop) then begin uos_stop(playerindex); end else begin uos_inputseek(playerindex,inputindex,0); MyPlaySound; // run 'MyPlaySound' procedure to loop and play the sound again end; The above code changes the form's caption while the sound is being played for the first time due to the uos_loopProcin(playerindex, inputindex, @MyPlayingNow) call, but there is no change to the caption if the sound is looped and played again. I would appreciate any help. Please also note that I am using uos with lazarus. Thanks. |
Administrator
|
Hello.
Did you try/study the consoleplayloop demo ? IMHO, for looping songs, it is a better way to do. Fre;D |
Thanks Fred - uos_loopProcin() anomaly now solved.
I replaced: uos_Play(playerindex); with: uos_Play(playerindex,3); following your suggestion to inspect the consoleplayloop demo, and the sound plays 3 times, calling the procedure associated with uos_loopProcin() while each sound is played. For those interested, and those who are embarrassing novices like myself, use the following to loop the sound endlessly until 'stopped' with code: uos_Play(playerindex,-1); Many thanks to Fred for the uos package and his valuable help in this forum. |
Administrator
|
In reply to this post by bfb101
Hello.
Nice that it works for you ;-) By the way, your previous code is not working because in EndProc you create the same player that the one playing. And after EndProc, that player will be destroyed... To make it works, you should use 2 players and switch from 1 to 2. (like in MorseTL demo). You could use something like this: var playerindex : integer = 0 ; .... MyPlaySound procedure (called to start sound play) // OK, keep your code. MyNowPlaying procedure (should be called while sound is being played) // OK, keep your code. ... MyPlayEnded procedure (called after sound play ends) // Here some change begin showmessage('sound play has just ended'); if (noloop) then else begin if odd(playerindex) then playerindex := 1 else playerindex := 0 ; // Add this to switch Player 1 <> Player 2 MyPlaySound; // run 'MyPlaySound' procedure to loop and play the sound again end; end; --------------------- |
Free forum by Nabble | Edit this page |