Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2004
    Messaggi
    27

    [java] come ottenere valore?

    Salve a tutti sono un nuovo utente del forum e vollei allietare la vostra giornata con un quesito a cui non riesco a dare risposta oramai da giorni...allora iniziamo...stò svolgendo un progetto in java (il mio primo progetto) e non riesco ad ottenere un risultato che mi è fondamentale per la riuscita del mio progetto.
    la situazione è questa: ho un package che mi consente (in teoria) di leggere i tag contenuti all'interno di un file mp3. questo package da quello che ho capito prende in input un file mp3 e ne legge i tag contenuti all'interno tramite una classe chiamata id3v2 che legge il contenuto nel momento in cui viene istanziata dall'arrivo di un nuovo mp3. Quello che fa dopo la classe principale (MP3File) è, richiamare una serie di metodi di tipo TagContent(un altra classe che consente di creare lo spazio per i dati) che incapsulano il dato.
    Adesso il mio problema è...come posso recuperare il dato incapsulato in una variabile di tipo TagContent???
    spero di essere stato chiaro....comunque vi posto il codice del package in modo da essere il + chiaro possibile

    questo è il codice che si trova nel file principale (MP3File)
    Codice PHP:
     public TagContent getAlbum() throws FrameDamagedException {
            
    TagContent ret TextFrameEncoding.read(id3v2"TALB");
            if (
    ret.getTextContent() == null) {
                try {
                    
    ret.setContent(id3.getAlbum());
                } catch (
    NoID3TagException e) {
                    
    // do nothing, content just stays at null
                
    }
            }
            return 
    ret;
        } 
    questo è quello che fà la classe tag content nello specifico del tag proposto
    Codice PHP:
       /**
         * Get content
         *
         * @return Textual content
         */
        
    public String getTextContent() {
            return 
    content_text
    mentre questo è quello che fà la classe TextFrame encoding che è un estensione di una classe astratta che serve a leggere il contenuto del tag
    Codice PHP:
      /**
         * Read content from ID3v2 tag.
         *
         * @param id3v2
         *            ID3v2 tag to read from
         * @param type
         *            Type of frame to read
         * @return content of tag
         * @exception FrameDamagedException
         *                If frame is damaged (e.g. too short)
         */
        
    public static TagContent read(ID3v2 id3v2String type)
                
    throws FrameDamagedException {
            return 
    read(trueid3v2type);
        } 
    quello che cerco di ottenere è il valore della variabile stringa corrispondente al frame TALB che sò è di tipo testuale quindi codificata come string....come posso fare???

  2. #2
    Utente di HTML.it
    Registrato dal
    Feb 2004
    Messaggi
    724
    String a=ret.getTextContent() ;

  3. #3
    Utente di HTML.it
    Registrato dal
    Mar 2004
    Messaggi
    27
    ho già provato in quel modo ma non riesce a risolvere ret questo anche se metto la classe che ho costruito all'interno del package....forse è meglio che posto anche la classe...

    Codice PHP:
    package de.vdheide.mp3;
    import java.io.*;
    public class 
    EstrazDati {


        
        public static 
    void main(String[] args) {
            
    // TODO Stub di metodo generato automaticamente
        
    System.out.println("Inserire il nome del file");
        
    InputStreamReader reader = new InputStreamReader (System.in); 
        
    BufferedReader myInput = new BufferedReader (reader);
        
    String str= new String();
        try {
         
    str myInput.readLine();
         
    MP3File m = new MP3File(str); 
             
    /*quello che mi hai suggerito*/
         
    String a=ret.getTextContent() ;
         
        }
        catch (
    IOException e) {
         
    System.out.println ("Si è verificato un errore: " e);
         
    System.exit(-1);
        }
        catch (
    de.vdheide.mp3.NoMP3FrameException e) {
             
    System.out.println ("Si è verificato un errore: " e);
             
    System.exit(-1);
            }
        catch (
    de.vdheide.mp3.ID3v2WrongCRCException e) {
             
    System.out.println ("Si è verificato un errore: " e);
             
    System.exit(-1);
            }
        catch (
    de.vdheide.mp3.ID3v2DecompressionException e) {
             
    System.out.println ("Si è verificato un errore: " e);
             
    System.exit(-1);
            }
        catch (
    de.vdheide.mp3.ID3v2IllegalVersionException e) {
             
    System.out.println ("Si è verificato un errore: " e);
             
    System.exit(-1);
            }

        
         
    System.out.println ("Hai scritto: "+str); 
        
        }


  4. #4
    Utente di HTML.it
    Registrato dal
    Feb 2004
    Messaggi
    724
    per forza... ret nn l'hai dichiarato... devi usare prima una cosa tipo questa
    TagContent ret = TextFrameEncoding.read(id3v2, "TALB");

  5. #5
    Utente di HTML.it
    Registrato dal
    Mar 2004
    Messaggi
    27
    eureka..........

    ho risolto grazie un milione

    il codice alla fine risulta questo

    Codice PHP:
    package de.vdheide.mp3;
    import java.io.*;
    public class 
    EstrazDati {

        public static 
    void main(String[] args) {
            
    // TODO Stub di metodo generato automaticamente
        
    System.out.println("Inserire il nome del file");
        
    InputStreamReader reader = new InputStreamReader (System.in); 
        
    BufferedReader myInput = new BufferedReader (reader);
        
    String str= new String();
        
        try {
         
    str myInput.readLine();
         
    MP3File m = new MP3File(str);
        
    TagContent ret TextFrameEncoding.read(m.id3v2"TALB"); 
         
    String a=ret.getTextContent() ;
         
    System.out.println(a);
        }
        catch (
    IOException e) {
         
    System.out.println ("Si è verificato un errore: " e);
         
    System.exit(-1);
        }
        catch (
    de.vdheide.mp3.NoMP3FrameException e) {
             
    System.out.println ("Si è verificato un errore: " e);
             
    System.exit(-1);
            }
        catch (
    de.vdheide.mp3.ID3v2WrongCRCException e) {
             
    System.out.println ("Si è verificato un errore: " e);
             
    System.exit(-1);
            }
        catch (
    de.vdheide.mp3.ID3v2DecompressionException e) {
             
    System.out.println ("Si è verificato un errore: " e);
             
    System.exit(-1);
            }
        catch (
    de.vdheide.mp3.ID3v2IllegalVersionException e) {
             
    System.out.println ("Si è verificato un errore: " e);
             
    System.exit(-1);
            }
        catch (
    de.vdheide.mp3.FrameDamagedException e) {
             
    System.out.println ("Si è verificato un errore: " e);
             
    System.exit(-1);
            }
        
         
    System.out.println ("Hai scritto: "+str); 
        
        }

    grazie ancora mi hai risolto un problema che mi attanagliava da 2 gg

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.