Results 1 to 8 of 8

Thread: Store Audio In Memmory

  1. #1

    Thread Starter
    Addicted Member mouse88's Avatar
    Join Date
    Mar 2009
    Location
    South Wales, United Kingdom
    Posts
    225

    Store Audio In Memmory

    Im wondering if it is possible to store an audio *.wav file in memmory so everytime I play it it doesn't have to be loaded?

    Is this possible?

  2. #2
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Store Audio In Memmory

    how do u want to play it? - if you are using direct show / mci / or media player just don't close the file

  3. #3

    Thread Starter
    Addicted Member mouse88's Avatar
    Join Date
    Mar 2009
    Location
    South Wales, United Kingdom
    Posts
    225

    Re: Store Audio In Memmory

    At the moment i'm just using:

    Code:
    My.Computer.Audio.Play("../../Resources/Test.wav")

  4. #4
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Store Audio In Memmory

    well prob not then - i mean audio.play does support a stream - so loading the file into one may be quicker

    Kris

  5. #5
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Store Audio In Memmory

    Code would be:

    vb Code:
    1. Dim s As New System.IO.FileStream("c:\alert.wav", System.IO.FileMode.Open, System.IO.FileAccess.Read)
    2.         My.Computer.Audio.Play(s, AudioPlayMode.Background)

    So make s global / form level variable (etc) and run the play line when u need it

  6. #6

    Thread Starter
    Addicted Member mouse88's Avatar
    Join Date
    Mar 2009
    Location
    South Wales, United Kingdom
    Posts
    225

    Re: Store Audio In Memmory

    Ok thanks this works when I play the sound once but when I play it a second time I get a System.InvalidOperationException?

  7. #7
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Store Audio In Memmory

    I believe you'd need to reset the position in the stream to 0, before attempting to play it again.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  8. #8

    Thread Starter
    Addicted Member mouse88's Avatar
    Join Date
    Mar 2009
    Location
    South Wales, United Kingdom
    Posts
    225

    Re: Store Audio In Memmory

    Ok problem solved it's now working fine thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width