Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9258969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:32:30+00:00 2026-06-18T12:32:30+00:00

I am trying to update the track number of files using AVMutableMetadataItem’s. I have

  • 0

I am trying to update the track number of files using AVMutableMetadataItem’s. I have been having some success except for AVMetadataFormatiTunesMetadata. I cannot seem to figure out what I need to set as the value to get this to work. I have tried to create an archive of a NSArray as follows

[NSKeyedArchiver archivedDataWithRootObject:[NSArray arrayWithObjects:
    [NSNumber numberWithUnsignedInt:13],
    [NSNumber numberWithUnsignedInt:32],
    nil]];

But I end up with a track and trackOf numbers that are way off. What exactly am I supposed to be passing in as the value for an AVMutableMetadataItem with a key of AVMetadataiTunesMetadataKeyTrackNumber?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:32:31+00:00Added an answer on June 18, 2026 at 12:32 pm

    It took me a very long time to figure that one out. Thanks to Apple’s Core Audio documentation, which says absolutely nothing about how to deal with it. Or any of the other keys for that matter. I had to examine an MP4 file with track information before I understood.

    Answer

    You need to assign it with an NSData containing the track information.

    The data must consists of four 16-bit big endian values, whereas the 2nd is the track number and the 3rd is the total tracks in collection. 1st and 4th should be zero.

    So basically you need to do this

    int16_t trackNumber = 1; // track number
    int16_t tracksInCollection = 12; // total number of tracks in collection
    int16_t data[4] = { 0, trackNumber, tracksInCollection, 0 };
    
    metadataItem.keySpace = AVMetadataKeySpaceiTunes;
    metadataItem.key = AVMetadataiTunesMetadataKeyTrackNumber;
    metadataItem.value = [NSData dataWithBytes:data length:sizeof(data)];
    

    Notice: The same approach is applied for the AVMetadataiTunesMetadataKeyDiscNumber key.

    A remarks on endianness

    If you don’t want to worry about byte-order, you can “borrow” a methods from the Berkeley sockets API. Or it might be a macro. Anyhow, it works like this:

    bigendianval = htons(val);
    

    or

    int16_t trackNumber = htons(myTrackNumberVariable);
    

    htons (Host to network short) will convert your 16-bit numbers to big endian – regardless of endianness of your own system. IP-networks are also big-endian, and therefore htons is reusable here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to update the contents of an element after running some php code.
I am trying to individually track the number of people who liked my facebook
I have been trying to setting up a function, which is getting the time
I allocated a number of labels and now I am trying to update the
I am having some issues getting my JS to work right. I am trying
I'm trying to get php to update a MySQL table using UPDATE statement but
I am trying to track down all stored procedures in a database that have
I'm trying to create some triggers for my MySQL tables to keep track of
I am trying update my version of sqlite3 on mac os x 10.5.7 I
I am trying update text views while this loop is processing. Here is my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.