Hallo ich arbeite zurzeit an einem Projekt welches die möglichkeit hat, MP3-Dateien zu sortieren. Soweit funktioniert auch alles ab und an schmeißt mir das Programm jedoch im Debugging eine Exception des Types System.overflow
Ein Ausnahmefehler des Typs "System.OverflowException" ist in YTGet.exe aufgetreten.
Zusätzliche Informationen: Die arithmetische Operation hat einen Überlauf verursacht.
Die Exception wird im Sub GetDuration geworfen: GetDuration()
Ein Ausnahmefehler des Typs "System.OverflowException" ist in YTGet.exe aufgetreten.
Zusätzliche Informationen: Die arithmetische Operation hat einen Überlauf verursacht.
Die Exception wird im Sub GetDuration geworfen: GetDuration()
Quellcode
- Private Mp3HeaderPosition, Mp3ClearSize As Integer
- ...
- Public Function GetDuration() As Integer
- Dim Duration As Integer = CInt(((Mp3ClearSize * 8) / GetBitrate()))
- Return Duration
- End Function
- Public Function GetBitrate() As Integer
- Dim BitrateArray() As Integer
- If GetMPEGType() = MPEGType.MPEG1 Then
- Dim TmpBitrateArray() As Integer = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320}
- BitrateArray = TmpBitrateArray
- Else
- Dim TmpBitrateArray() As Integer = {8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}
- BitrateArray = TmpBitrateArray
- End If
- If Not IsVBR() Then
- Select Case Mp3HeaderBitsStr.BitrateBitsString
- Case "0001" : Return BitrateArray(0) * 1000
- Case "0010" : Return BitrateArray(1) * 1000
- Case "0011" : Return BitrateArray(2) * 1000
- Case "0100" : Return BitrateArray(3) * 1000
- Case "0101" : Return BitrateArray(4) * 1000
- Case "0110" : Return BitrateArray(5) * 1000
- Case "0111" : Return BitrateArray(6) * 1000
- Case "1000" : Return BitrateArray(7) * 1000
- Case "1001" : Return BitrateArray(8) * 1000
- Case "1010" : Return BitrateArray(9) * 1000
- Case "1011" : Return BitrateArray(10) * 1000
- Case "1100" : Return BitrateArray(11) * 1000
- Case "1101" : Return BitrateArray(12) * 1000
- Case "1110" : Return BitrateArray(13) * 1000
- End Select
- Else
- Dim CXingHeader As XingHeader = GetXingHeader()
- Dim LastByte, AverageFrameLenght, AverageBitrate As Integer
- 'For more info see : http://www.multiweb.cz/twoinches/MP3inside.htm#MP3FileStructure
- With CXingHeader
- LastByte = CInt((.TOC(99) / 256) * .FileLenght)
- AverageFrameLenght = CInt(.FileLenght / .NumberOfFrames)
- AverageBitrate = CInt(((AverageFrameLenght * GetSamplingRateFreq()) / 144) / 1000)
- End With
- Return AverageBitrate * 1000
- End If
- End Function