Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metadata.picture returns file data {name:'song.mp3' ......} #1

Open
monibzia opened this issue Jan 7, 2016 · 8 comments
Open

metadata.picture returns file data {name:'song.mp3' ......} #1

monibzia opened this issue Jan 7, 2016 · 8 comments

Comments

@monibzia
Copy link

monibzia commented Jan 7, 2016

No description provided.

@nazar-pc
Copy link
Owner

nazar-pc commented Jan 7, 2016

Does it happen for any file? If so, can you provide some sample file?
This library is used in https://github.com/nazar-pc/CleverStyle-Music and I never seen this happening.

@Fabiencdp
Copy link

Same here, got the same file in "picture" property, for all files tested.
But i'm not sure if i use it correctly, Can you provide some exemple ?

Thanks

@nazar-pc
Copy link
Owner

Here is an example in CoffeeScript in mentioned project: https://github.com/nazar-pc/CleverStyle-Music/blob/master/html/cs-music-player/script.coffee#L229
Better show your example so that I can suggest something.

@Fabiencdp
Copy link

Thanks for your reply,

Here is how i use it, i work on a ionic project, and browse audio file across an android device, for each audio file, i fetch some data, the parser work very well and fast, but "picture" return the same File object.

`getFile: function (fileEntry) {

        var deferred = $q.defer();

        fileEntry.file(function(file) {

            if ( file.type !== null && file.type.indexOf('audio') < 0 ) return deferred.resolve(false);

            // Create media object
            var media = new Media(fileEntry.fullPath);

            // Get meta and stuff
            parse_audio_metadata(file, function (tag) {

                console.log(tag);

                var result = {
                    coverUrl: tag.picture ? tag.picture.localURL : false,
                    description: '',
                    id: media.id,
                    provider: 'device',
                    score: '',
                    title: tag.title,
                    artist: tag.artist,
                    album: tag.album,
                    genre: tag.genre,
                    url: file.fullPath,
                    media: media,
                };

                deferred.resolve(result);

            }, function parseError(error) {
                console.log(error);
                deferred.resolve(false);
            })

        })

        return deferred.promise;

    },

`

See attach for the log of 'tag' response
image

@nazar-pc
Copy link
Owner

Did you try to show that image on screen?
Because it is actually taken from that file, I think this might be a reason why you got such result. Also compare size of picture with size of source file whether they differ anyhow.
It should be fine, since other tags were extracted properly.

@Fabiencdp
Copy link

Thanks again, the size of File and Picture are the same, start and end looks good.
But how can you display an image with that kind of blob ?

@nazar-pc
Copy link
Owner

url = URL.createObjectURL(metadata.picture) and you'll get something you can use as URL to add it on the page. Also if you work with multiple such objects do not forget to call URL.revokeObjectURL(url) afterwards to avoid memory leaks.

@Fabiencdp
Copy link

It fail too with message :

Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided.

I think something dont work with the Cordova File Plugin, i'll try to find a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants