mp3 player problems on mac os

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default mp3 player problems on mac os

    Hi!

    I'm newbie in flex and I have a problem when I run flex mp3 player on mac OS.
    Here is the site where I get the player.
    [url]http://labs.flexcoders.nl/2007/02/21/easy-to-use-mp3player-version-003/[/url]. There
    are no problems in windows OS. The problem in mac is it you will need to click
    stop button first and after that click now the play button. But in windows you
    will only click the play button. Is there something wrong in the code? Or I
    will need to install plugins for MAC.

    Please help me.

    Thanks in advance,

    Ridge.


    anyway here are the codes:


    Mp3Sample.mxml:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:controls="nl.fxc.controls.*"
    xmlns:gauge="gauge.*"
    xmlns:local="*"
    width="100%"
    height="100%"
    backgroundAlpha="0"
    backgroundGradientAlphas="[]"
    backgroundColor="#000000"
    color="#FFFFFF" viewSourceURL="srcview/index.html">

    <mx:Style>
    Text{
    font-weight: normal;
    }
    Label{
    font-weight: bold;
    }
    .dialGauge {
    frameSkin: ClassReference("gauge.skins.alternatives.DialSkin" );
    coverSkin: ClassReference("gauge.skins.alternatives.DialSkin" );
    needleSkin: ClassReference("gauge.skins.alternatives.DialSkin" );
    }
    </mx:Style>

    <controls:MP3Player
    id="mp3_player"
    url="assets/mp3/test3.mp3"
    autoPlay="false"
    repeat="{repeat_btn.selected}"
    volume="{volume_slider.value/100}"
    pan="{pan_slider.value}"/>

    <mx:HBox id="control_container" horizontalAlign="left" verticalAlign="top"
    verticalScrollPolicy="off" horizontalScrollPolicy="off">
    <mx:Image source="assets/skin/stop.png" buttonMode="true"
    click="mp3_player.stop()"/>
    <mx:Image source="assets/skin/pauze.png" buttonMode="true"
    click="mp3_player.pauze()"/>
    <mx:Image source="assets/skin/play.png" buttonMode="true"
    click="mp3_player.play()"/>

    <gauge:Gauge
    id="volume_slider"
    width="50"
    height="50"
    liveDragging="true"
    value="50"
    minimum="0"
    maximum="100"
    styleName="dialGauge"/>

    <gauge:Gauge
    id="pan_slider"
    width="50"
    height="50"
    liveDragging="true"
    value="0"
    minimum="-1"
    maximum="1"
    styleName="dialGauge"/>
    </mx:HBox>

    <mx:HSlider minimum="0" maximum="{mp3_player.length}"
    value="{mp3_player.position}" width="{control_container.width}"/>

    <mx:Button id="repeat_btn" toggle="true" label="Repeat" selected="false"/>

    <mx:Spacer height="20"/>

    <local:PlayerInfoView mp3Player="{mp3_player}"
    width="{control_container.width}" verticalScrollPolicy="off"
    horizontalScrollPolicy="off"/>

    <local:ID3InfoView id="id3_view" id3="{mp3_player.id3}"
    width="{control_container.width}" verticalScrollPolicy="off"
    horizontalScrollPolicy="off"/>

    </mx:Application>


    MP3PLayer.as:

    /*
    MP3Player version 0.3

    Simple mp3 player.

    use:
    - url, pathe to the mp3-file;
    - autoAutplay;

    properties you can read:
    - id3, info;
    - length, length in ms;
    - sLength, formatted length "0.00";
    - sPosition, formatted position "0.00";
    - position, position in ms;
    - pMinutes, position minutes;
    - pSeconds, position seconds;

    //-->added 21 februari 2007
    - repeat;
    - volume;
    - pan;

    TODO:
    - set position, this is for example for slider-drag;
    - and other cool stuff
    - boring stuff like documentation

    Created by Maikel Sibbald
    [email]info@flexcoders.nl[/email]
    [url]http://labs.flexcoders.nl[/url]

    Free to use.... just give me some credit
    */

    package nl.fxc.controls{
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.events.ProgressEvent;
    import flash.events.TimerEvent;
    import flash.media.ID3Info;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.media.SoundMixer;
    import flash.media.SoundTransform;
    import flash.net.URLRequest;
    import flash.utils.ByteArray;
    import flash.utils.Timer;

    import mx.binding.utils.BindingUtils;
    import mx.binding.utils.ChangeWatcher;
    import mx.core.UIComponent;
    import mx.utils.ObjectUtil;

    public class MP3Player extends UIComponent{

    [Bindable]public var id3:ID3Info;
    [Bindable]public var length:Number;
    [Bindable]public var sLength:String = "0.00";
    [Bindable]public var sPosition:String = "0.00";
    [Bindable]public var pMinutes:Number = 0;
    [Bindable]public var pSeconds:Number = 0;
    [Bindable]public var position:Number = 0;

    private var _url:String;
    private var _autoPlay:Boolean;
    private var _isPlaying:Boolean;
    private var _repeat:Boolean;
    private var _volume:Number = 0;
    private var _pan:Number = 0;

    private var soundInstance:Sound;
    private var soundChannelInstance:SoundChannel;
    private var urlRequest:URLRequest;
    private var pausePosition:Number;
    private var soundBytes:ByteArray;

    public function MP3Player():void{
    this.explicitHeight = 0;
    this.soundInstance = new Sound();
    this.soundTransform = new SoundTransform();
    this.setupListeners();
    }

    public function set url(value:String):void{
    this._url = value;
    this.urlRequest = new URLRequest(this._url);
    this.soundInstance.load(this.urlRequest);
    }

    public function get url():String{
    return _url;
    }

    public function set repeat(value:Boolean):void{
    this._repeat = value;
    }

    public function get repeat():Boolean{
    return this._repeat;
    }

    public function set autoPlay(value:Boolean):void{
    this._autoPlay = value;
    }

    public function get autoPlay():Boolean{
    return this._autoPlay;
    }

    [Bindable]
    public function set volume(value:Number):void{
    this._volume = value;
    this.invalidateDisplayList();
    }

    public function get volume():Number{
    return this._volume;
    }

    [Bindable]
    public function set pan(value:Number):void{
    this._pan = value;
    this.invalidateDisplayList();
    }

    public function get pan():Number{
    return this._pan;
    }

    public function get isPlaying():Boolean{
    return this._isPlaying;
    }

    override protected function updateDisplayList(unscaledWidth:Number,
    unscaledHeight:Number):void{
    if(this._autoPlay && !this._isPlaying){
    this.play();
    }
    if(this.soundChannelInstance != null){
    this.soundChannelInstance.soundTransform = new SoundTransform(this.volume,
    this.pan);
    }
    }

    /******************************************CONTROLS ***************************
    ********************/
    private function setupListeners():void{
    this.soundInstance.addEventListener(Event.COMPLETE , completeHandler);
    this.soundInstance.addEventListener(Event.OPEN, openHandler);
    this.soundInstance.addEventListener(Event.ID3, id3Handler);
    this.soundInstance.addEventListener(IOErrorEvent.I O_ERROR,
    ioErrorHandler);
    this.soundInstance.addEventListener(ProgressEvent. PROGRESS,
    progressHandler);

    this.addEventListener( Event.ENTER_FRAME, function():void {
    if(soundChannelInstance != null){
    position = soundChannelInstance.position;
    pMinutes = Math.floor(soundChannelInstance.position / 1000 / 60);
    pSeconds = Math.floor(soundChannelInstance.position / 1000) % 60;
    sPosition = pMinutes+":"+(pSeconds < 10?"0"+pSeconds:pSeconds);
    }
    });
    }

    public function play():void{
    if(!this._isPlaying){
    this._isPlaying = true;
    this.soundChannelInstance = this.soundInstance.play(this.pausePosition);
    this.soundChannelInstance.addEventListener(Event.S OUND_COMPLETE,
    soundCompleteHandler);
    this.invalidateDisplayList();
    this.pausePosition = null;
    }
    }

    public function pauze():void{
    this.pausePosition = this.soundChannelInstance.position;
    this.stop();
    }

    public function stop():void{
    this._isPlaying = false;
    this.soundChannelInstance.stop();
    }


    /******************************************HANDLERS ***************************
    ********************/
    private function completeHandler(event:Event):void {
    this.dispatchEvent(event);
    }

    private function openHandler(event:Event):void {
    this.dispatchEvent(event);
    }

    private function id3Handler(event:Event):void {
    this.id3 = this.soundInstance.id3;
    }

    public function soundCompleteHandler(event:Event):void {
    this.stop();

    if(this.repeat){
    this.play();
    }
    }

    private function ioErrorHandler(event:IOErrorEvent):void {
    this.dispatchEvent(event);
    }

    private function progressHandler(event:ProgressEvent):void {
    if(this.soundInstance != null){
    this.length = this.soundInstance.length;
    var tempMinutes:Number = Math.floor(this.length / 1000 / 60);
    var tempSeconds:Number = Math.floor(this.length / 1000) % 60;

    this.sLength = tempMinutes+":"+(tempSeconds <
    10?"0"+tempSeconds:tempSeconds);
    }
    this.dispatchEvent(event);
    }

    }
    }

    ridgeback1105 Guest

  2. Similar Questions and Discussions

    1. PROBLEMS WITH FLASH PLAYER 9
      I have downloaded Flash Player 9 but it doesn't work. When I open a website with a flash file, it doesn't load the file. I can see only some sites,...
    2. Web player problems
      Hey everybody just wondering if some1 could help me out? I am having problems playing any of the videos on foxes prison break site, no web player...
    3. Problems with IE7 and Flash Player 9
      There seems to be some problems with VBscript/JavaScript Flash version 'sniffing' with Internet Explorer 7 and Flash Player 9. This may be due to...
    4. Flash Player 9 Problems
      hi I was wondering why flash player 9 opens up frame links in a new window, even when in the html code it's explicitly written to open it up in a...
    5. Flash Player 8 problems
      I am having problems with FlashPlayer 8 and Internet Explorer 6. Immediately after downloading Flash Player 8 I begin to experience problems and...
  3. #2

    Default Re: mp3 player problems on mac os

    Try assigning an initial value to the pausePosition variable in MP3Player.as,
    probably in the constructor:

    public function MP3Player():void{
    this.pausePosition = 0; //assign the value of 0 here
    this.explicitHeight = 0;
    this.soundInstance = new Sound();
    this.soundTransform = new SoundTransform();
    this.setupListeners();
    }

    TS

    VarioPegged Guest

  4. #3

    Default Re: mp3 player problems on mac os

    Great! It is working now! Thank you very much for your help! That was very much appreciated!
    ridgeback1105 Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139