Coder Social home page Coder Social logo

PopularimeterFrame about node-taglib-sharp HOT 2 CLOSED

benrr101 avatar benrr101 commented on September 26, 2024
PopularimeterFrame

from node-taglib-sharp.

Comments (2)

benrr101 avatar benrr101 commented on September 26, 2024 1

Yep, the library does indeed support popularimeter frames! The docs for the frame is here but that probably doesn't tell you too much about how to use it. Same as TagLib#, the PopularimeterFrame isn't exposed via the standardized Tag interface, so you'll have to manipulate the frames directly. When you get to manipulating the frames directly, it can be a bit confusing. Here's an example:

import {
    File,
    Id3v2Tag,
    Id3v2FrameClassType,
    Id3v2FrameIdentifiers,
    Id3v2PopularimeterFrame,
    TagTypes
} from "node-taglib-sharp";

const myFile = File.createFromPath("myFile.mp3");
const id3v2Tag = <Id3v2Tag>myFile.getTag(TagTypes.Id3v2, true);

// Read a popularimeter frame
const popularimeterFrames = id3v2Tag.getFramesByClassType<Id3v2PopularimeterFrame>(Id3v2FrameClassType.PopularimeterFrame);
console.log(popularimeterFrames[0].playCount);
console.log(popularimeterFrames[0].rating);

// Write a popularimeter frame directly
popularimeterFrames[0].user = "[email protected]"; // ID3v2 Spec says it should be an email
popularimeterFrames[0].playCount = 10n; // It's a BigInt
popularimeterFrames[0].rating = 100; // It's a byte between 0 and 255
myFile.save();

// Write a new frame instead
const newPopularmieterFrame = Id3v2PopularimeterFrame.fromUser("abc@123");
newPopularmieterFrame.playCount = 10n;
newPopularmieterFrame.rating = 100;

id3v2Tag.removeFrames(Id3v2FrameIdentifiers.POPM);
id3v2Tag.addFrame(newPopularmieterFrame);
myFile.save();

Let me know if you have any questions or need clarification!

from node-taglib-sharp.

digimezzo avatar digimezzo commented on September 26, 2024

Thanks a lot for taking the time to help out! That's an amazing example. I should be able to get it working with this info.

from node-taglib-sharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.