0
0

Hi.

I’m using VB6 and FMOD 3.6.

Since the callback functions does not work, I use this line in a timer to detect end of stream:

If FSOUND_Stream_GetPosition(lStream) >= FSOUND_Stream_GetLength(lStream)

In some MP3 files the GetPosition never reaches the GetLength, and my program will hang on that file.

Please HELP!!

BTW: I have seen some examples here that use only = and not >=. In many songs the stream will go past GetLength.

David

  • You must to post comments
0
0

Im pretty sure it is also called when the song is finished.

  • You must to post comments
0
0

X-Mas wish ๐Ÿ˜›

I wish that it (or another callback) would only be activated when the stream has come to the end.

This is the way that the Windows Media Player control works, and it’s (I think) better.

The reason ?

To easier skip to the next song, and not when the user has pressed the stop button.

The way it works now we have no indication of why the callback was triggered…

Or maybe IsPlaying can help ?

David

  • You must to post comments
0
0

I don’t think that is such a good idea. 1st WMP is laggy as hell, you need a super computer now adays to keep up with it. It eats massive amounts of cpu and memory.

I don’t think adding such kludges to FMOD would be a very good idea at all.

If your app can’t figure out why the stream ended, ie via a user interuption or ended then I personally think its time for an overhaul of your application.

++Cire.

  • You must to post comments
0
0

The stream will never go past GetLength, it is the way that FMOD works, when GetTime reaches GetLength the song will automatically stop playing, say for example the GetLength is 300 seconds, the stream shouldn’t continue playing after 300 seconds has past.

  • You must to post comments
0
0

All you really need is a simple timer using IsPlaying. Heres some sample code that should work perfectly.

[code:112hd9lh]
If Channel = 0 Then Exit Sub

If (FileType = "stream" And FSOUND_IsPlaying(Channel) = False) Or (FileType = "module" And FMUSIC_IsPlaying(Module) = False) Then

'Code to do stuff at the end of the song.

End If

[/code:112hd9lh]

It shouldn’t be too complicated. ๐Ÿ˜€

  • You must to post comments
0
0

Actually it resets gettime to 0, and stops playing.

  • You must to post comments
0
0

Cire:

I don’t talk about using the Windows media Player Control, but I like the end of stream feature from it.

And, yes. Of course I know what the user has done, but in my wish is that end of stream should be that, meaning end of stream and not stream has halted, or paused.

So we have different opinions.

Gabriel:

It will require some extra flags to check is the stream is stopped (stop button) or we wont know the difference between reaching the end of the stream and stop.

All:

I still think that the end of stream callback should be that, and not a “not playing anymore” callback.

David

  • You must to post comments
0
0

Then it shouldn’t be a problem. All you have to do in the timer is to check If FSOUND_Stream_GetTime(lStream) = FSOUND_Stream_GetLengthMS(lStream) and set the timer for 1ms so that it checks every millisecond. That should work fine, it should detect the end of the file before gettime resets to 0.

  • You must to post comments
0
0
  1. Check FSound_Stream_Load for the parameter to check correct lenght of streams (wav/mp3/ogg…)
  2. Use a timer. save the current position in a long variable, if it doesn’t change till the next check (1 second should do), you can stop your song
  • You must to post comments
0
0

Hiyas David, I’am gona give ya a big tip to check to see if a stream is playing or not. Remeber the channel handle that is returned when you execute your call FSOUND_Play… Well that channel handle you should remember and keep track of in a global variable.

Now to check to see if its busy, simply add a function like this..
[code:27gf466s]
Public Function IsPlaying() As Boolean
IsPlaying = False

If lngChanHandle = 0 Then Exit Function

If FSOUND_IsPlaying(lngChanHandle) = 1 Then IsPlaying = True

End Function
[/code:27gf466s]

Thats all thier is to it, Of course you will want to make sure you init FMOD with looping off. And simply call this from time to time, shoudl it return false, the stream is done, otherwize it is still playing.

Hope this helps.

++Cire.

  • You must to post comments
0
0

I still fail to see the logic behind all this…

I think your problem is that you start and leave your timers running at all times. This method is causing you grief. The best bet is …When the application is started doing something, for example playing a mp3. You start a timer, The timer would be removed when the user presses stop. The only goal of this timer is to check to see if the tune has reached its end. If so then select another song, or repeat song, or whatever..

IMHO there is no need to add such kludges to FMOD, its the fastest most efficent sound system out there, lets keep it that way!

++Cire.

  • You must to post comments
0
0

First it not very good practice to use a one millisecond timer interval. It might not trigger at the exact moment, and is a waste of processing power.

Thank you for the IsPlaying tip. But in my case is not very helpful at this problem. What if the user has stopped the music ? It’s not correct to assume that when not IsPlaying that he wants to skip to the next song as I do at the end of stream.

My solution is to have a NewFile flag. This is set to true when a stream starts to play. At the end of my timer function I set the NewFile flag to false.

In the timer function I check if the NewFile is false and that the current GetTime is smaller than the previous GetTime. The result is that this will not trigger the first time the timer function is called and it will correctly handle if the user has skipped to another song (re-started the stream).

I don’t know if this makes sense to you, but it works great.

All this will not be necessary when the callback function works correctly in VB (hopefully next version).

  • You must to post comments
0
0

[size=117:1qails51][u:1qails51][b:1qails51]The way I did it in my program, and it work very well, I never had problem with that:[/b:1qails51][/u:1qails51][/size:1qails51]

[b:1qails51][u:1qails51]In the Running Sub[/u:1qails51] (the one that is always running, for VU, position, etc.):[/b:1qails51]

[code:1qails51]If FSOUND_IsPlaying(Channel) = False And _
FSOUND_GetPaused(Channel) = False Then
Arreter False
Exit Sub
End If[/code:1qails51]

“Arreter” is my stoping function

[u:1qails51][b:1qails51]In the Function “Arreter”:[/b:1qails51][/u:1qails51]

[code:1qails51]Public Sub Arreter(Bouton As Boolean)
With Form1
If Bouton = True Then FSOUND_Stream_Stop Stream
If .LectureContin.Checked = True And Bouton = False Then
If .ListView1.Tag + 1 > .ListView1.ListItems.Count Then .ListView1.Tag = 0
ListViewIndex IIf(.LectureAleatoir.Checked, _
Int((.ListView1.ListItems.Count * Rnd) + 1), _
.ListView1.Tag + 1)
.Command1_MouseDown 1, 3, 0, 0
Else
[i]Stop the Running Sub, if not this function _
will be called until you start an other song
Stuff to do when nothing is playing[/i]
End If
End With
End Sub[/code:1qails51]

“Bouton” is to know if the button stop has been pressed
—> “TRUE” when the function is called when I press the stop button
—> “FALSE” when it is called from the Running Sub
“.LectureConti” is a menu item to know if you want continuous play
“.ListView1.Tag” is to know which song was the last
“ListViewIndex” is a function to select a ListView item and “EnsureVisible” that item
“LectureAleatoir” is a menu item for Random playing
“Command1” is the button that play song

  • You must to post comments
0
0

You know, Brett has an StdCall version of FMOD, if you really want to do this with callbacks you could request a copy from Brett.

  • You must to post comments
0
0

[quote:1t5pjjz2]
Thank you for the IsPlaying tip. But in my case is not very helpful at this problem. What if the user has stopped the music ? It’s not correct to assume that when not IsPlaying that he wants to skip to the next song as I do at the end of stream.
[/quote:1t5pjjz2]

Well ideally whatever type of timer you are using to check for the ending for the song would be stopped if the user stopped the song. Your timer which checks for the end of the song would be simply something like…

[code:1t5pjjz2]
If IsPlaying = False then
...start new song
endif
[/code:1t5pjjz2]

Anyhow best of luck.

++Cire.

  • You must to post comments
0
0

I have looked at the SDTCALL version of FMOD.

Have a question:

The EndOfStream callback is only valid when the stream is stopped and not when finished playing the stream.

Is this correct ?

  • You must to post comments
Showing 16 results
Your Answer

Please first to submit.