News:

SMF - Just Installed!

Main Menu

Recent posts

#1
Hi Terry,

this issue should have been fixed inside the latest build 14.4.2.1 of the multimedia engines AdjMmsEng.dll and AdjMmsEng64.dll.

You can update your installation by uninstalling the current version and by downloading the latest setup package available on our website.

Hope this helps.

Kind regards

Severino Delaurenti
MultiMedia Soft

#2
Audio playback and audio management components / EV_SOUND_DONE infinite loop
Last post by Terry - September 26, 2024, 07:39:25 AM
Hi,

I tried to load a sound file from the website through the "m_audioAPI.LoadInternetStream(0,"http://localhost/test.mp3")" command.
When the playback is completed, the EV_DOWNLOAD_COMPLETE event will be triggered first, and then the EV_SOUND_DONE event will be triggered infinitely.

The execution logs is as follows

13:10:30.0695|[1]|[EV_SOUND_STOPPED]
13:10:30.1013|[1]|[EV_STREAM_CONNECTING]
13:10:30.3553|[1]|[EV_DOWNLOAD_BUFFERING] URL=http://localhost/test.mp3 STREAMING_BUFFERING
13:10:30.3678|[1]|[EV_STREAM_LOADED] STREAM_LOAD_OK http://localhost/test.mp3
13:10:30.3678|[1]|[EV_SOUND_PLAYING] URL=http://localhost/test.mp3
13:10:30.3678|[1]|[EV_DOWNLOAD_BUFFERING] URL=http://localhost/test.mp3 STREAMING_PLAYING
13:11:18.3746|[1]|[EV_DOWNLOAD_COMPLETE] URL=http://localhost/test.mp3
13:11:24.2355|[1]|[EV_SOUND_DONE] URL=http://localhost/test.mp3
13:11:24.2524|[1]|[EV_SOUND_DONE] URL=http://localhost/test.mp3
13:11:24.2685|[1]|[EV_SOUND_DONE] URL=http://localhost/test.mp3
13:11:24.2854|[1]|[EV_SOUND_DONE] URL=http://localhost/test.mp3
13:11:24.2854|[1]|[EV_SOUND_STOPPED] URL=http://localhost/test.mp3
13:11:24.2854|[1]|[EV_SOUND_DONE] URL=http://localhost/test.mp3
13:11:24.3026|[1]|[EV_SOUND_DONE] URL=http://localhost/test.mp3
13:11:24.3186|[1]|[EV_SOUND_DONE] URL=http://localhost/test.mp3
.
.
infinite loop


Is it normal ....?

Terry
#3
Hello,

stopping the playlist causes the stop of the currently playing song so the SoundStopped event is raised.

Kind regards

Severino Delaurenti
MultiMedia Soft
#4
Hi,

Executing the 'PlayListStop' command will not trigger any events, right?

Kind Regards

Terry
#5
Hello,
you are welcome ;D

Kind regards

Severino Delaurenti
MultiMedia Soft

#6
I was so careless, thank you.
#7
Hello,

the main error is caused by the fact that you are not passing the correct file pathname to the PlayListAddItem method. Try to change the following code

    For Each file As String In Directory.GetFiles(m_strInputPathname)
          err = m_audioAPI.PlayListAddItem(0, m_strInputPathname, 0)
          Console.WriteLine("{0} {1}", file, err.ToString)
    Next

with the following code:

    For Each file As String In Directory.GetFiles(m_strInputPathname)
          err = m_audioAPI.PlayListAddItem(0, file, 0)
          Console.WriteLine("{0} {1}", file, err.ToString)
    Next

Another problem is the fact that you set the following code inside the handler of the enumPlayerEvents.EV_SOUND_DONE event, causing the playlist being stopped after the first song

m_bSoundDone = True
please, move that line inside the handler of the enumPlayerEvents.EV_PLAYLIST_DONE event instead.


Another important point: The original source code of the Visual Basic.NET version of the PlayerCmdLine project (so also your code) contains the following line:

    Thread.Sleep(50)
Be sure to replace this line with the following one or your application may experience several malfunctions

    m_audioAPI.ConsoleWait(50)

Hope this helps.

Severino Delaurenti
#8
Hi,

I discovered that the AudioDjStudioApi cannot play audio files in a playlist within a command line program.
I modified the sample program "PlayerCmdLine" so that the program can load a directory containing audio source files and play them, but it seems to be unsuccessful. It can load a single audio file and play but a playlist. The program code is as follows. Is there anything I'm missing?



'---------------------------------------------------------------
Namespace PlayerCmdLine
   Friend Class Program
      Private Shared m_bSoundDone As Boolean = False
        Private Shared m_strInputPathname As String = ""
        Private Shared addrCallbackForPlayersEvents As CallbackForPlayersEvents = New CallbackForPlayersEvents(AddressOf PlayerCallback)
        Private Shared m_audioAPI As AudioDjStudioApi.AudioDjStudioApiObj = New AudioDjStudioApi.AudioDjStudioApiObj()


      Private Shared Sub PlayerCallback(ByVal nEvent As enumPlayerEvents, ByVal nPlayer As Int16, ByVal nData1 As Int32, ByVal nData2 As Int32, ByVal fData3 As Single, ByVal pBufferUnicode As IntPtr, ByVal nBufferLength As Int32)
         Select Case nEvent
            Case enumPlayerEvents.EV_SOUND_DONE
                    Console.WriteLine(Constants.vbCr & nEvent.ToString)
                    m_bSoundDone = True

                Case enumPlayerEvents.EV_SOUND_PLAYING
                    Console.WriteLine(Constants.vbCr & "Status: Sound playing...")

                Case enumPlayerEvents.EV_PLAYLIST_LOAD_DONE
                    Console.WriteLine(Constants.vbCr & nEvent.ToString)
                    If nData1 = 0 Then
                        Console.WriteLine(Constants.vbCr & "Error loading playlist")
                    End If
                Case enumPlayerEvents.EV_PLAYLIST_DONE
                    Console.WriteLine(Constants.vbCr & nEvent.ToString)

                Case enumPlayerEvents.EV_PLAYLIST_LOAD_STARTED
                    Console.WriteLine(Constants.vbCr & nEvent.ToString)

                Case Else
               Return
         End Select
      End Sub

      Shared Sub Main(ByVal args As String())
         If args Is Nothing Then
                Console.WriteLine("args is null") ' Check for null array
                Return
            End If
            ' read command line arguments
            Dim prefixes As String() = New String() {"/i:"}
            Dim cae As CmdArgExtractor = New CmdArgExtractor(prefixes, "/"c, ":"c)

            If (Not cae.ValidArgsPrefixes(args)) Then
                Return
            End If

            Dim my2dArr As String(,) = cae.GetArgsTwoDimArray(args)
            Dim i As Integer = 0
            Do While i < my2dArr.GetLength(1)
                Select Case my2dArr(0, i)
                    Case "i"
                        m_strInputPathname = my2dArr(1, i)
                End Select
                i += 1
            Loop
            Console.Clear()
            m_audioAPI.InitSoundSystem(1, 0, 0, 0, 0)
            m_audioAPI.CallbackForPlayersEventsSet(addrCallbackForPlayersEvents)
            m_audioAPI.DisplayVUMeter.Create(0, IntPtr.Zero)
            m_audioAPI.StreamVolumeLevelSet(0, 100, enumVolumeScales.SCALE_LINEAR)
            Dim err As enumErrorCodes
            Select Case True
                Case Directory.Exists(m_strInputPathname)
                    For Each file As String In Directory.GetFiles(m_strInputPathname)
                        err = m_audioAPI.PlayListAddItem(0, m_strInputPathname, 0)
                        Console.WriteLine("{0} {1}", file, err.ToString)
                    Next
                    Console.WriteLine(m_audioAPI.PlayListExecute(0, True).ToString)

                Case File.Exists(m_strInputPathname)
                    err = m_audioAPI.LoadSound(0, m_strInputPathname)
                    Console.WriteLine("{0} {1}", m_strInputPathname, err.ToString)
                    Console.WriteLine(m_audioAPI.PlaySound(0).ToString)

            End Select

            If m_audioAPI.LastError <> enumErrorCodes.ERR_NOERROR Then
                Console.WriteLine("Cannot load file due to error " & m_audioAPI.LastError.ToString)
            Else
                Dim info As ConsoleKeyInfo = New ConsoleKeyInfo()
                Do While Not Console.KeyAvailable
                    If m_bSoundDone Then
                        Exit Do
                    End If
                    Thread.Sleep(50)
                Loop
                m_audioAPI.StopSound(0)
                Console.WriteLine(Constants.vbCrLf & "Status: Stop")
            End If

            m_audioAPI.Dispose()
        End Sub
    End Class
End Namespace

'---------------------------------------------------------------

Terry
#9
Hello, you are welcome.

In this case unfortunately no specific event is available but you may obtain the total duration by applying a couple of arithmetic operations:

- in "Insert" mode you can simply add the duration of the previous session, which can be obtained through the RecordedSound.GetDuration method, to the duration of the current session as reported by the RecordingDuration event

- in "overwrite" mode is a bit more tricky because you need to keep count of the overwrite position and add to this position the duration of the current session as reported by the RecordingDuration event:

   a) if the result of this sum is smaller than the duration of the previous session, which can be obtained through the RecordedSound.GetDuration method, then the total duration is still represented by the value returned by the previous call to the RecordedSound.GetDuration method

   b) if the result of this sum is higher, then the new total duration will be the sum between the overwrite position and the duration of the current session as reported by the RecordingDuration event.

In both cases, please, keep count that the RecordedSound.GetDuration method needs to be invoked before starting the recording session or it will return the error ERR_RECORDER_BUSY (-64).

Hope this helps.

Kind regards

Severino Delaurenti
MultiMedia Soft
#10
Audio recording components / Re: Obtaining total record tim...
Last post by mjividen - May 07, 2024, 03:39:19 PM
Thanks for the answer.  My problem is not APPEND but is displaying the total recording length in INSERT and OVERWRITE modes.  (I'm writing code in VB on Visual Studio).