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

  • SEARCH
  • Home
  • 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 8201287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:45:28+00:00 2026-06-07T06:45:28+00:00

I am able to successfully create a simple app that plays sound using the

  • 0

I am able to successfully create a simple app that plays sound using the code below. The problem however is if I change the asset from being an mp3 to an m4a (with aac encoding). No sound is produced, yet the duration of the composition matches the length of the added sample.

NSError *error;

AVMutableComposition* composition = [AVMutableComposition composition];
AVURLAsset* audioAsset1 = [[AVURLAsset alloc]initWithURL:[NSURL URLWithString:@"http://www.myserver.com/sample.mp3"] options:nil];

AVMutableCompositionTrack *audioTrack1 = [composition addMutableTrackWithMediaType:AVMediaTypeAudio 
                                                                  preferredTrackID:kCMPersistentTrackID_Invalid];

[audioTrack1 insertTimeRange:CMTimeRangeMake(kCMTimeZero, audioAsset1.duration)
                     ofTrack:[[audioAsset1 tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0]
                      atTime:kCMTimeZero
                       error:&error];

NSLog(@"%@", error);

playerItem = [AVPlayerItem playerItemWithAsset:composition];

player = [AVPlayer playerWithPlayerItem:playerItem];

[player play];

Can anyone help?

  • 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-07T06:45:29+00:00Added an answer on June 7, 2026 at 6:45 am

    I ended up posting this question everywhere and ended up creating a bug report with apple.

    How I solved the issue is to have a step at the start that downloads the m4a into the apps temp directory and then add it to the composition from there. Works like a charm.

    I won’t go into detailed code on how to do it but as my app makes use of the popular AFNetworking library, here is the key parts.

    1: AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:songURLRequest];
    2: NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"song.m4a"];
    3: operation.outputStream = [NSOutputStream outputStreamToFileAtPath:filePath append:NO];
    

    Line 1: Setup an AFHTTPRequestOperation
    Line 2: Setup a local path as a string where the file will be saved
    Line 3: Set the outputStream on the AFHTTPRequestOperation to the local path

    Hope this helps someone in the future!

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

Sidebar

Related Questions

I was able to successfully run an RF model using some R code I
I am trying to create a simple app for the iPad that with play
I am trying to create virtual desktop. I complete successfully.But i am not able
I am successfully able to authenticate Facebook and Google accounts using my Oauth2 servlets.
I was able to successfully configure and generate the build folder (KinectSLAM6D/build.). However, when
Hi I'm able to successfully integrate iphone app with facebook framework. But I need
I see Google doing this all the time. They are able to successfully create
Based on several good articles I have been able to successfully create a few
I am trying to create a simple COM server using Python 2.7 on 64
I have a very simple bit of code that won't work, and have no

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.