Playing WAV file

Discussion in 'iOS Development' started by deepp, Mar 11, 2009.

  1. deepp

    deepp New Member

    Joined:
    Sep 4, 2008
    Messages:
    73
    Likes Received:
    0
    Hi,
    I am trying to play wav sound files and i am able to play sound files but not all. When i try to play those wav files whose length is less than 10 seconds it does not play. And a WAV files whose size is above 150 KB and length is more than 20 second are also not playing.For bigger size file i can understand that as this files are compresses so i need to do is this
    if (audioFormat.mBytesPerPacket == 0 || audioFormat.mFramesPerPacket == 0) {
    packetDescriptions = (AudioStreamPacketDescription*)malloc(
    numPacketsToRead * sizeof(AudioStreamPacketDescription)
    );
    } else {
    packetDescriptions = NULL;
    }

    but when i do this it gives compiler error that invalid L-value.
    I am using SpeakHere sample codes files to play sound file.
    Can anyone help me find the solution for this.
    And what could be the reason for small sound file as i have tried using SoundEffect.h and SoundEffect.m files also but no help it does not play those WAV files.

    And sound files which i am getting played are 5MB in size in 30 second lengthy.

    Thanks.
  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    back it up. if you need to play a sound, why not use avfoundation?

    Code:
    #import <AVFoundation/AVAudioPlayer.h>
    
    ...
    
    AVAudioPlayer* blah = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:@"/tmp/music.mp3"]];
    [blah play];
    can't be simpler =]
  3. deepp

    deepp New Member

    Joined:
    Sep 4, 2008
    Messages:
    73
    Likes Received:
    0
    Thanks gojohnybboi ,but as i need to develop an application for Iphone SDK 2.0 i cant use AVAudioPlayer.Iphone SDK 2.0 does not support this frame.So have been using Audiotoolbox.
  4. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    You should always be developing with the newest SDK.
  5. deepp

    deepp New Member

    Joined:
    Sep 4, 2008
    Messages:
    73
    Likes Received:
    0
    Yes you both people are very right but can you give me solution for this 2.0 version for Audiotoolbox also when i try to play MOV video file i get Quicktime decoder DIV6 decoder loading error ans same i get for for audio for some of the audio files though i can play few WAV files and m4v video files but few gives error.Please some one help me i just need to know the reasong for DIV 6 decoder error.
  6. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    Why do you want 2.0 version, give me that, at and I'll see what I can do.
  7. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    you better start compiling on the newest sdk, because eventually the newer firmwares are going to depend on newer and newer sdks. if you're compiling for 2.0, its only a matter of time before your app just _stops_ is my guess. you never know, but its way better to do it that way.

Share This Page