Differenze tra le versioni di "Estrarre informazioni da un file MP3 con le funzioni esterne del API di Smpeg"

Da Gambas-it.org - Wikipedia.
(Creata pagina con 'La libreria di SMPEG consente di gestire file ''mpeg'', come estrarre informazioni di carattere generale relative al file. Per poter utilizzare le risorse della libreria libs...')
 
Riga 26: Riga 26:
 
  <FONT color=gray>' ''SMPEG* SMPEG_new(const char *file, SMPEG_Info* info, int sdl_audio)''
 
  <FONT color=gray>' ''SMPEG* SMPEG_new(const char *file, SMPEG_Info* info, int sdl_audio)''
 
  ' ''Create a new SMPEG object from an MPEG file. This function returns a new SMPEG object.''</font>
 
  ' ''Create a new SMPEG object from an MPEG file. This function returns a new SMPEG object.''</font>
  Private Extern SMPEG_new(file$ As String, infoP As Pointer, sdl_audio As Integer) As Pointer
+
  Private Extern SMPEG_new(file$ As String, infoP As SMPEG_Info, sdl_audio As Integer) As Pointer
 
   
 
   
 
  <FONT color=gray>' ''void SMPEG_delete( SMPEG* mpeg )''
 
  <FONT color=gray>' ''void SMPEG_delete( SMPEG* mpeg )''

Versione delle 06:21, 14 mar 2014

La libreria di SMPEG consente di gestire file mpeg, come estrarre informazioni di carattere generale relative al file.

Per poter utilizzare le risorse della libreria libsmpeg è necessario richiamare nell'applicazione Gambas la libreria (nella sua attuale versione): libsmpeg-0.4.so.0.1.4


Mostriamo di seguito un semplice codice per estrarre le informazioni generali di un file audio mp3:

Public Struct SMPEG_Info
  has_audio As Integer
  has_video As Integer
  width As Integer
  height As Integer
  current_frame As Integer
  current_fps As Float
  audio_string[80] As Byte
  audio_current_frame As Integer
  current_offset As Integer
  total_size As Integer
  current_time As Float
  total_time As Float
End Struct

Library "libsmpeg-0.4:0.1.4"

Private Const audio As Integer = 1

' SMPEG* SMPEG_new(const char *file, SMPEG_Info* info, int sdl_audio)
' Create a new SMPEG object from an MPEG file. This function returns a new SMPEG object.
Private Extern SMPEG_new(file$ As String, infoP As SMPEG_Info, sdl_audio As Integer) As Pointer

' void SMPEG_delete( SMPEG* mpeg )
' Delete an SMPEG object
Private Extern SMPEG_delete(mp As Pointer)


Public Sub Main()

 Dim info As New SMPEG_Info
 Dim smpeg As Pointer
 Dim percorsoFile As String


  percorsoFile = "/percorso/del/file.mp3"

  smpeg = SMPEG_new(percorsoFile, info, audio)

  With info
   If .has_audio = 0 Then Error.Raise("Errore: il file caricato non è un file audio !")
   Print "File audio: "; File.Name(percorsoFile)
   Print "Caratteristiche principali: "; .audio_string.ToString()
   Print "Dimensione del file audio: "; .total_size; " byte"
   Print "Durata del brano: "; Date(0, 0, 0, 0, 0, 0, .total_time * 1000)
 End With

' Va in chiusura:
  SMPEG_delete(smpeg)

End