Basic streaming of mp3 file example

Hi,
I'm just trying to understand how to work with sound.  Although you can find many mp3 player codes available to use it's difficult to customize them if don't really know what's going on. So I set about looking at the sound examples in the help menu of flex development.  The following code below is supposed to take an mp3 file and stream it.
But the error get is "-1120- access of undefined property s , req and context  " on lines where those are used.  I don't even know what req and context mean but they seem to be defined, so I don't get what I'm missing and why it won't work?  Please put me out of my misery.  I'm saving it as an mxml file.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
        <![CDATA[
    import flash.media.Sound;
import flash.media.SoundLoaderContext;
import flash.net.URLRequest;
var s:Sound = new Sound();
var req:URLRequest = new URLRequest("pride.mp3");
var context:SoundLoaderContext = new SoundLoaderContext(8000, true);
s.load(req, context);
s.play();
    ]]>
    </mx:Script>
</mx:Application>

Hi.
Your
s.load(req, context);
and
s.play();
lines should be in a method (function), not directly in the mxml script tag.
Try using the creationComplete event if you want the sound to start playing without user interaction.

Similar Messages

  • BUG? Streaming an mp3-file does not work a second time with iPhone 4

    Hi,
    I was trying to stream a mp3-file from a server and listen to it on my iPhone. At the first time it worked all right, but when I wanted to listen a second time I got the error message "The server is not configured correctly.", after quicktime started, and nothing happened.
    I tried to reset the iPhone and again got the error message.
    This is the link: http://kunst.museumsportal.de/76/236.mp3
    Does anybody experience similar problems when clicking on the link with an iPhone 4? Do I miss something?
    Thanks for help or suggestions,
    Klaus

    There are 3 things you can try.
    Hard reset -Hold home and power button until apple logo is displayed -Release let device reboot -test it out.
    If issue persists -go to Settings>gerneral>reset>reset all settings -test.
    Issue persisting still??
    Last but not least restore and setup as new, this will erase EVERYTHING make sure contacts/calendars are in the iCloud or synced in windows Contacts/Addressbook/outlook, or Addressbook on a mac, and Calendars in Outlook, or iCal
    make sure to transfer your purchases, in iTunes windows or mac - File at top left - Transfer purchases.
    Transfer photos via iPhoto, windows scanner camera wizard, or Windows Photo Gallery
    then follow  http://support.apple.com/kb/ht1414

  • Save streamed MP3 file?

    Our app includes a music player which streams MP3s from a server. We would like to be able to stream the MP3, and save it to a cache on disk once it has fully downloaded.
    I am using the load() method of the Sound class to stream the MP3 so that playback can begin before the file is fully downloaded. I can listen for the Event.COMPLETE event to indicate that the MP3 has finished downloading, but the Sound class offers no way to access the original file and save it to disk (the extract() method returns uncompressed sound data which is much too large to write to the disk).
    Is there any method to download an MP3 file that will allow us to stream the MP3 file as it is downloading, and save it to disk when the download is complete, without downloading it twice?

    Unless you can find an MP3 encoding library that could take the extract() data and convert it back with minimal effort, I think your only option is to save the mp3 using the File and FileStream classes. One thing you could try is to use a File object to download the file, and while it is downloading, you have the sound object play the data contents of the File object downloading the mp3. I just tried a quick test locally and it worked on my desktop. You will have to try it from an actual server to know how well it can work in that environment, but it is at least worth a shot.
    import flash.filesystem.File;
    import flash.filesystem.FileMode;
    import flash.filesystem.FileStream;
    import flash.events.ProgressEvent;
    import flash.events.Event;
    import flash.media.Sound;
    import flash.net.URLRequest;
    var file:File = File.applicationDirectory.resolvePath("gravity.mp3");
    file.addEventListener(ProgressEvent.PROGRESS, onProgressEvent);
    file.addEventListener(Event.COMPLETE, onFileLoadComplete);
    file.load();
    var sound:Sound;
    function onProgressEvent(e:ProgressEvent):void {
      if (sound == null) {
      file.removeEventListener(ProgressEvent.PROGRESS, onProgressEvent);
      sound = new Sound(new URLRequest(file.url))
      sound.play();
    function onFileLoadComplete(e:Event):void {
      file.removeEventListener(Event.COMPLETE, onFileLoadComplete);
      var saveFile:File = File.desktopDirectory.resolvePath("gravity2.mp3");
      var fs:FileStream = new FileStream();
      fs.open(saveFile, FileMode.WRITE);
      fs.writeBytes(file.data, 0, file.data.length);
      fs.close();
    What this code is doing is creating a File object with, in this case, a path to an MP3 in the same folder as the test FLA I created. This would be a path to your server stored MP3. Then you setup the event listeners for progress and complete. I used progress to know that the file had actually started to be downloaded to then trigger the initialization of my Sound object. Depending on someones network connection and the size of the MP3, it could be a good idea to use progress to know that the file has gotten X percentage done before trying to play the file.
    For testing purposes in my progress event, I just checked to see if the Sound object had been initialized yet, and if it hadn't then set sound equal to a new Sound object with the File.url property for the URLRequest() and then told it to play.
    Once the File object dispatched the complete event to indicate that the download finished, I created a new File object for the purpose of saving it to the filesystem using the FileStream class. Using FileStream to save the file allows for no user interaction to save the MP3.
    There may be better ways to handle my method, but I can't think of any at the moment. As far as I know, the second File object, which I named "saveFile", is required in order to actually save the downloaded MP3 object because Im not too familiar with File manipulation. The only downside I can think of is that you have a copy of the MP3 is memory and would need to null out the File object that loaded the MP3 to free up memory.

  • How to stream .mp3 file?

    Hi All,
    I have success full installation of Flash media server 4 in my linux machine.
    I am in need of stream the .mp3 file over network.
    Please any help me on this.
    Thanks,
    Hariharan V.

    There are two ways to access the mp3 files over http - progressive download and http streaming.
    For the first, all you need to do is open a flash client that supports http playback. For this, copy the mp3 file and place inside the vod folder inside webroot. To access the file over http, give the url as -
    http://server-name/vod/sample.mp3.
    A more efficient way of doing media streaming is to use Http Dynamic Streaming -
    http://help.adobe.com/en_US/HTTPStreaming/1.0/Using/WS8d6ed60bd880807c48597a9e1265edd6cc0- 8000.html  and
    http://help.adobe.com/en_US/HTTPStreaming/1.0/Using/WS9463dbe8dbe45c4c-c126f3b1260533756d- 7ffc.html
    But f4fpackager does not supports packaging of mp3 files directly. It can package flv and f4v codec files. Though you can package audio only files that contain mp3 codecs but not directly with mp3 extensions.
    Go through these tutorials for details about the second method.
    Let me know if you need some help understanding it.
    Regards,
    Apoorva.

  • Can jmf broadcast mp3 files?convert mp3 to wav format to enable streaming?

    Hello... can jmf broadcast mp3 file format audio files.. so that it can accessible.. since it is playable... or does it require conversion to another for in audio in order for it to be streamed on LAN... Thanks and more power to JAVA..

    Man, have you ever opened Logic before? If you had you would have noticed that these instructions are for Logic and yes you will obtain 44.1/16 files if you choose these options in the "copy/convert" menue.

  • Quick Time downloading mp3 file instead of streaming it

    When I click on an mp3 file on a webpage which normally streams, it now starts downloading instead of streaming. Using the latest version.

    Thanks for your help. Actually after my last post in saying it only happened in Firefox I had a further look in Firefox - Options - Applications - it showed that Quick Time default player was set to play mp3 files. I changed this to the Quick Time plug in and it worked. Thanks again.

  • Best way to stream MP3 files with ColdFusion

    I was looking for a kind of a built in player look in that
    all the user has to do is click and it will start playing within
    the browser. Some of the files are even 48MB long so if I can
    reduce that too that would be good. client goes on conferences and
    plan to record more conferences and we would like to host them on
    the site.
    Any Help?

    Making pod casts:
    http://www.podcastingnews.com/articles/How-to-Podcast.html
    http://www.windowsdevcenter.com/pub/a/windows/2005/04/05/create_podcasts_with_pc.html
    Flash players for MP3s:
    http://wimpyplayer.com
    Jukebox from
    http://swishzone.com
    --Nancy O.
    "Brandon" <[email protected]> wrote
    in message
    news:et99hk$svu$[email protected]..
    > I'm looking for recommendations about the best way to
    publish mp3 files.
    I
    > have a client that is a church that wants their staff to
    be able to upload
    > mp3 files on a weekly basis from a web client and have
    those files
    > automatically be included in a podcast feed as well as
    have a "play"
    option
    > and a "download" option. I know how to setup the front
    end . . . any
    > suggestions on the best way to implement this on the
    back end (such as
    > extensions or services)?
    >
    > --
    > Brandon
    >
    http://www.presentationsdirect.com
    >

  • I visit a website which has podcasts.when I click listen icon on a page, it opens a small new window where mp3 file streams.

    But I want to open mp3 file in new tab on the page.Normally when I click a link on any website, links open in new tab. but on this site (elspod.com) there are icons not links .the site is elspod.com

    you can try out this page
    http://www.eslpod.com/website/show_podcast.php?issue_id=13731485
    if you click the listen icon on the page , a new windows is likely to open to play mp3 file..could I play/open this mp3 in a new tab instead of in new window

  • SWF to play mp3 files located on the server

    Hello,
    Does anyone know if it is possible to create an SWF file that can play mp3 files directly from the server, without the need for a streaming media server or external JS.
    And also for the application to read the current directory its located in and build a playlist based on the files inside.
    any information of examples would be greatly appreciated.
    Peter.

    As for loading and playing the files there is no issue.  Simply load them as you would load any file.  You can even use a relative path if they are in the same folder as the SWF, or a sub-folder that is in the folder with the SWF.
    As for looking at the server directory for what files are there, and using them - I know of no way to do this.  That doesn't mean it is impossible, just that I haven't come across a method in my experience.
    What I typically do is to archive the list of files in an XML file, and load the XML.  I know, that adds an extra step, and an extra file, but it is the easiest method for approximating what you want to do.
    Let me edit this response.
    You could use javascript, or a server language to grab the list of files in the directory and pass it into Flash via the ExternalInterface classes.

  • Mp3 file to podcast

    Ok, since iTunes is now version 11 I haven't been able to tag/create
    mp3 files (recorded radio streams) so that that they show up/play
    in iTunes or phone. Going to 'get info' on file just won't go from a 'music'
    file to a 'podcast' file. Anyone have any ideas?

    First thing is that a file (music or otherwise) cannot be "made into a podcast" by changing the media type. It never could be.
    Poeple have told me, in past discussions on this forum, and in very strong terms, that I'm wrong about this, but the fact remains that something is only a Podcast if it has been downloaded from the internet "as a Podcast", which means: "through the Podcast delivery method".
    Perhaps what has happened is that Apple have fixed something that was incorrect (being able to change something into a Podcast simply by changing the Media Type).
    As for you actual issue, tagging something so that you can play it on your iPod; I'm not sure I understand what the problem is.
    Okay, so you have recorded some audio, which is now presumably on your computer as an MP3 file. Did you add any tagging information when you created the MP3 file, for example in Audacity? If you did, or if you can, then that should show up in iTunes. If not, you can modify the tagging once the file has been imported into your iTunes Library. 
    Presumably you could import the audio before iTunes 11, and that procedure hasn't changed as far as I'm aware, so you should still be able to import the recordings. Once imported, it can be played in iTunes, even before changing any of the tag information. It can also be added to an iPhone.
    So what is it about the tagging that you don't like, apart from not being able to "make it a Podcast". How does making it a Podcast change anything?
    I ask, so that I can understand. Then I can possibly offer another solution.

  • Are mp3 files seekable over RTMP with FMS 3.5?

    I had an OSMF sample running on my dev laptop with Wowza Media Server because it's OSX. I use the following line to setup an mp3 stream over RTMP: var audio:AudioElement = new AudioElement(new NetLoader(), new URLResource(new URL(selectedMediaSource)));
    With Wowza, the audio is seekable, but when I change over to FMS, the file still plays but the mediaPlayer is no longer seekable so the scrub bar doesn't work. The code is based off of the ExamplePlayer sample that ships with OSMF and uses a mediaPlayerWrapper to manage visibility of the controls in the UI.
    Do I need something on the server side to allow the seek function? Is this not possible over FMS? Or is there just a much better way to code this?
    Thanks.

    Actually, it looks like mediaPlayer.seekable == true, but the file won't seek. The easiest way to duplicate the problem is just to use the ExamplePlayer sample and modify the 'AllExamples.as' file. You can change the URL to point to any mp3 file in an FMS streaming directory for the "Streaming Audio" example.
    It seems like the easiest fix is to convert the mp3 file to an flv and the seek function works again. I would rather not convert all of the mp3 files to flv, but at least it's functional. My guess is that FMS does not send the duration of the file for the mp3 format so the player can't seek.

  • Why can't my mp3 files be downloaded from my website?

    Hello there,
    I am creating a HTML website for a client and they want a 'podcast' page with a listing of their podcasts. The idea is that the viewer can click on the link on the web page and have a choice of either listening to the podcast streamed through the website or they can download it to put on an ipod if they want. The trouble is that when I click on the link, I can only listen to the mp3 files streamed. Normally when I upload a file, e.g. a PDF file, it can be downloaded when its link is clicked on. Am I doing something wrong? I need a 'download' option too.
    I've read about RSS feeds and find it terribly confusing and can't find a clear, simple explanation anywhere on how to do it.
    My webpage is: http://alfierobertsinstitute.ca/podcasts.html
    (It's still a mess as it's a work in progress.)
    I would really appreciate some help or advice regarding my problem.
    PS. The podcasts are not embedded in my HTML. I have them uploaded in a separate Podcast folder on my server space.
    Thank you in advance.
    Martha
    Message was edited by: peachespeaches

    Look at this RSS example.  View source.  It's an XML file with a list of audio files. You can subscribe to the feed and have it saved to iTunes etc...for import into iPod, or Live Bookmarks, or Browser bookmarks or some other RSS aggregator on your PC.
    Or you can click on individual links to launch your player.
    http://www.plaino.com/mp3s5/wimpy_podcast.php
    My suggestion is to provide options for as many users as possible.  Not everyone has an iPod, not everyone has Flash player capability.
    Read this again
    http://www.wimpyplayer.com/docs/mp3/index.php?m=playlists&p=playlist.podcast.html
    Nancy O.
    Alt-Web Design & A
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb

  • Brasero Cannot burn cd using mp3 files [SOLVED]

    Everytime i try to burn an audio CD from mp3 files brasero gives me an error saying "Not suitable for audio or video media." I have all of the gstreamer plugins installed so thats not the problem. Ive seen a few posts on forums for other distros about the same problem but no real fixes. Most people just suggest using something else. I want to use brasero. I like the way it integrates with banshee. Has anyone else seen this issue?
    Edit: Solved via Post #10 in this thread
    Last edited by donfrenchiano (2013-05-15 12:48:18)

    Everytime i try to burn an audio CD from mp3
    You'll have to turn .mp3 into .wav to make an audio CD. Or did you mean a data CD with .mp3 files on it? Google how to make an audio CD.
    lame --decode file.mp3 output.wav
    Are there any other burning programs that can do this?
    You bet. Here are the basics. Add whatever options you wish.
    Make .iso of files to burn to CD
    mkisofs -R -J /path/to/files -o /path/to/output.iso
    Disk with multiple folders on it.
    genisoimage -J -r -pad -graft-points dir1/=/path/files dir2/=/path/files dir3/=/path/files > filename.iso
    Burn .iso to disk
    growisofs -Z /dev/sr0=/path/name.iso
    wodim speed=8 -tao dev=/dev/sr0 /path/file.iso
    Burn DVD from files example
    growisofs -use-the-force-luke=tty -Z /dev/sr0 -J -r -speed=8 -dvd-compat -pad -graft-points /path/file.avi /path/file.avi
    Write Audio CD from a folder of .wav files
    cdrecord -v dev=/dev/sr0 speed=8 -audio -pad *.wav
    http://linux.die.net/man/1/wodim
    http://linux.die.net/man/8/mkisofs
    http://linux.die.net/man/1/genisoimage
    http://linux.die.net/man/1/growis

  • Multiple mp3 file concatenation

    Ok, so im working on this project where I need to combine multiple mp3 files. Right now I am doing this with 5 mp3 files for example. I know I need to convert the mp3 files to wav format in order to make this work. My question is how exactly do I convert mp3 files to wav format?
    The next step is to open these 5 files that have been converted to wav format and combine them into 1 large wav file. The method I have been trying to use for this involves audio input streams and sequence input streams. I really do not know much about using either of these and could really use some help. Can anyone give me some example code of how wav concatenation through audio streams can be done?
    Lastly, the one large wav file needs to be converted back to mp3 format. I really have no idea how to do this either.
    So those are the parts of my project which I am having trouble with. Any help at all is appreciated being that I need to turn this project in in a few days. Thank you so much!

    went back and rechecked the artwork.  Removed what was there and it did work.  Thanks so much!!!

  • AVTransmit2.java --stream an rtp file multiple times (AutoLoop)

    Hi,
    I am trying to stream a short .wav file continueously emulating the function of (AutoLoop). For example, i want to stream a 5 sec .wav file over and over such that it looks like a long audio file. So on the receiving side, it wouldn't be reconized that the file streamed was only 5 sec long.
    Any ideas how to do that using AVTransmit2?
    Any help/guidance is appreciated

    whatup wrote:
    Thanks captfoss for your prompt and detailed reply... maybe i should have given you some more details:I think you're misunderstanding the links. Those links are not my suggestions, they are starting points to implement my suggestions.
    All of my suggestions achieve "what you're looking for"...
    Now the concat is basically taking n input files, combining them and saving them into one output file (if i understood it correctly). That is what concat does. It is also an example of a pass-through DataSource, and is solely intended to be example code of the concept I laid out in my explanation to help you code the explanation.
    if you think above task (trasmit a short audio file for ~3 days) using your previous guidance is not easy to establish, how about the following: That's how to do it... there's no reason to disregard any of those methods I proposed, except the first if your DataSource isn't positionable.
    I looked at JMStudio tool and they have the AutoLoop option. i looked at the source code they create MediaPlayer while they start trasmitting but could not undestand the connection/hook between trasmitter and MediaPlayer such that autoloop function of the player kickstars while trasmitting. JMStudio src can be found here: (http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/samples/jmapps-src-211.zip)
    The loop functionality is implemented by the MediaPlayer class, and it handles it internally (I believe) via the method I explained above (option #1).
    I don't believe this functionality is available for transmitting data, simply playing it.

Maybe you are looking for

  • How do I run a table over multiple pages?

    Hi I write TV scripts using a simple two column table which can be many rows long - how can I get Pages to automatically run the table over multiple pages whilst still allowing me to cut and paste and rearrange the script? This is simple in Word and

  • App error 240 on bb curve 9320

    I downloaded an app called pic shuffler for bbm and it told me to restart my device as usual but when it turned back on it said app error 240 reset so i reset it like 5 more times still didnt work please helppp

  • Zen Micro A/C power cord opti

    Hi All, My Micro recharges just fine when plugged into the USB of my computer with Creative software. However, it will not charge using USB on other computers. Also, I tried plugging in my Blackberry charger (output 5V,?0.7A)?to the USB port. The Mic

  • PL/SQL Equivalent to the condition "No inline validation errors displayed"

    Hello, I've seen this on another thread but can't find it. I need two conditions to be true to show a region: a value is not null and no inline validation errors are showing. Does anyone know the PL/SQL (API call?) to retrieve the number of errors be

  • HT3209 I have purchased a complete season of a TV show via my Apple TV.

    I am trying to figure out how to manage purchased show via Apple TV. I am finding it takes 1 hour and 40 minutes to download each episode. I am not finding where the episodes are downloaded to. I looked at the TV shows downloaded in iTunes via my Mac