aadsm / jsmediatags

Media Tags Reader (ID3, MP4, FLAC)
Other
748 stars 128 forks source link

Error: No suitable file reader found for... #51

Closed MillmooRon closed 7 years ago

MillmooRon commented 7 years ago

I have your example with the file selection button working OK and it reads the TXXX tags in my mp3 fine.

If I try to use the example which specifies a filename e.g. new jsmediatags.Reader("filename.mp3")

I get "Error: No suitable file reader found for filename.mp3"

What is the correct syntax for referencing a) a file in the same directory as the html, and b) a URL in the form file:// ?

I have tried everything I can think of, but I'm not pro so don't really know what I'm doing wrong!

lallsonu commented 7 years ago

I'm getting the same issue, everything was working fine until late last week. Any help would be appreciated

aadsm commented 7 years ago

@MillmooRon are you doing this in node? To read local files you need to use node. If you're using the package on a browser then you need to pass the http:// path to it.

@lallsonu can you give me more details? running node/web? Did this happen after you update to the latest version? I pushed a new version a month ago, if so can you try with the previous one: 3.3.2?

MillmooRon commented 7 years ago

I am running in a browser. I have some HTML which displays information about the currently playing file from a media server. The server has its own js library which allows access to some common information (artist, album, etc.) but I want to get something from TXXX tags which it does not support. I can get a string that contains the file: URL of the current track.

I'm not familiar with node.js. Could I pass the file: URL that my browser Javscript function returns to an external node.js function to read the tags and then return a string value to Javascript?

If so I will investigate node.js, but not if I'm trying to do something which is impossible!

Is there another way to create a file object without pressing a button on a form?

aadsm commented 7 years ago

@MillmooRon if you're running in the browser then you need to use http://... URL's, so filename.mp3would never work in this situation. It should be as simple as that.

lallsonu commented 7 years ago

It happens because jsmediatags can't read id3 v1.1 , if you upgrade a music file to id3 2.x , it works. Would be nice to have that fixed S

On Sun, Mar 26, 2017 at 7:06 PM, António Afonso notifications@github.com wrote:

@MillmooRon https://github.com/MillmooRon are you doing this in node? To read local files you need to use node. If you're using the package on a browser then you need to pass the http:// path to it.

@lallsonu https://github.com/lallsonu can you give me more details? running node/web? Did this happen after you update to the latest version? I pushed a new version a month ago, if so can you try with the previous one: 3.3.2?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aadsm/jsmediatags/issues/51#issuecomment-289324030, or mute the thread https://github.com/notifications/unsubscribe-auth/AFXFeFdwIz-ykU0_Sek4dl4wJLKBRCAWks5rpu9ZgaJpZM4Mi8Oa .

-- Kind regards,

Sukhwinder (Sonu) Lall University of Waterloo Honours System Design Engineering ('15) Term 4B

"To get what we have never had we must do what we have never done"

MillmooRon commented 7 years ago

Thank you! Made some progress. It now works on some browsers but unfortunately not the one I need it for.

On Midori on a Raspberry Pi I get the following error:

TypeError: 'undefined' is not a function (evaluating 'ArrayBuffer.isView(d)')

at jsmediatags.min.js:10

also, on Firefox on Ubuntu

TypeError: ArrayBuffer.isView is not a function

Any ideas why I might be getting this?

MillmooRon commented 7 years ago

I commented out the first part of the if statement at line 219 of jsmediatags.js to leave only:

value: function _concatData(dataA, dataB) { return dataA.concat(dataB); }

and it works OK on my browser now.

I don't really know what I did but it seems to work!

aadsm commented 7 years ago

@MillmooRon Depending on the browser version that function might not be implemented: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView

I can add a check for isView too and fallback to concat. It would fail if the data is a TypedArray though, but if it works in your case it clearly isn't.

aadsm commented 7 years ago

@lallsonu What do you mean? It should support ID3v1.1: https://github.com/aadsm/jsmediatags/blob/master/src/ID3v1TagReader.js#L47

davidweisscode commented 5 years ago

Hi @aadsm and everyone,

I try to get this running inside my Android cordova ionic app.

Reading tags of online hosted .mp3 from inside the app works fine.

jsMediaTags.read("https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3", {

Reading tags from the device's local filesystem is not working.

this.file.resolveLocalFilesystemUrl("file:///storage/emulated/0/Music/MyFolder/01.%20MySong.mp3").then((fileEntry) => {
        jsMediaTags.read(fileEntry, {

The fileEntry object I am sending into jsmediatags is looking like this:

FileEntry {
  isFile: true,
  isDirectory: false,
  name: "01. MySong.mp3",
  fullPath: "/Music/MyFolder/01. MySong.mp3",
  filesystem: FileSystem,
  nativeURL: "file:///storage/emulated/0/Music/MyFolder/01.%20MySong.mp3"
}

This results in the following, known error

Uncaught (in promise): Error: No suitable file reader found for [object Object]

As a total beginner, I am wondering: Is this possible at all? Any help or comment would be super nice and appreciated :-)

davidweisscode commented 5 years ago

Just in case someone else is struggling with reading tags from the local filesystem in a cordova app. I solved my issue described in the above comment using the following snippet.

  /**
  *  Read ID3 tags from local files
  *  @param fullPath   Path in the /Music/ directory
  *  @returns tag      Object containing tags and metadata
  */
  getTags(fullPath) {
    return new Promise<{tags: any}>((resolve, reject) => {
      this.file.resolveDirectoryUrl(this.file.externalRootDirectory).then((dirEntry) => {
        this.file.resolveLocalFilesystemUrl(dirEntry.nativeURL + fullPath).then((fileEntry) => {
          jsMediaTags.read(fileEntry.toInternalURL(), {
            onSuccess: function(tag) {
              console.log("TAG", tag.tags.artist, tag.tags.album, tag.tags.title,);
              resolve(tag);
            },
            onError: function(error) {
              console.log("ERROR", error);
              reject();
            }
          });
        });
      });
    });
  }