When you say that you change the autoplay properties to true – where do you mean?  In the mxml tag or in the script that is loading the music file.  Also – how are you loading the media?  The medialPlayer.load() loads the media but does not play it.

 

Mind sharing a bit more?

 

Jeff

Founder

Flex Authority

http://www.flexauthority.com

 

We are actively seeking contributors for the site.  Have a sample that you want to share with the world?  Send it to us!


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Venkata Krishnan Natarajan
Sent: Sunday, June 12, 2005 5:33 AM
To: flexcoders@yahoogroups.com
Cc: [EMAIL PROTECTED]
Subject: [flexcoders] Auto loading mediaController

 

Hi,

I used the "complete" event to change the selectedItem of the grid to
selectedItem+1, which loads the next song in the grid to the controller. But
the controller is paused. I have to click the play button to play the song.
I tried changing the autoplay properties of the controller but it wont work.
Any suggestions? I have attached the mxml and actionscript code for
reference. Please advice.

Thanks
Venkat

-------------mxml-------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
marginBottom="0" marginLeft="0" marginRight="0" marginTop="0"
backgroundColor="#FFFFFF" horizontalAlign="center" xmlns="*">

  <mx:Model id="model1" source="Tamilmakkal.xml"/>

  <mx:Script source="DragEventHandlers.as"/>

    <mx:Canvas width="770" height="100%" cornerRadius="10"
borderColor="#666666" dropShadow="true">
      <mx:HBox width="100%" height="100%" horizontalAlign="left"
marginLeft="0" marginRight="0" horizontalGap="0" marginBottom="0"
marginTop="0" verticalGap="0" >

          <mx:Panel title="ALBUMS" height="100%" width="200"  marginBottom="0"
marginRight="0" marginTop="0" marginLeft="0" >
           <mx:VDividedBox marginBottom="0" marginRight="0" marginTop="0"
marginLeft="0" width="100%" height="100%">

                    <mx:List height="50%" width="100%" dataProvider="{model1.Music.Album}"
change="this.selectedItem=event.target.selectedItem" borderThickness="1"
borderStyle="solid" buttonColor="#FFFFFF"/>

                    <mx:DataGrid id="datagrid1" dragEnabled="true" 
multipleSelection="true" dataProvider="{selectedItem.file}" width="100%"
height="50%">
                        <mx:columns>
                          <mx:Array>
                              <mx:DataGridColumn headerText="Title" columnName="filename" />
                          </mx:Array>
                        </mx:columns>
                    </mx:DataGrid>

            </mx:VDividedBox>
            </mx:Panel>

            <mx:Panel title="PLAYLIST" verticalAlign="middle" height="100%"
width="540" barColor="#A2C7F4">

            <mx:DataGrid id="dg" width="100%" height="100%"
dragEnter="doDragEnter(event)" dragExit="doDragExit(event)"
dragDrop="doDragDrop(event)" dragOver="doDragOver(event)"
dragComplete="doDragComplete(event)">
                    <mx:columns>
                        <mx:Array>
                          <mx:DataGridColumn headerText="Title" columnName="filename" />
                          <mx:DataGridColumn headerText="Size" columnName="filesize" />
                        </mx:Array>
                    </mx:columns>
                   </mx:DataGrid>

              <mx:ControlBar width="100%">
             <mx:VBox width="100%">
                        <mx:MediaDisplay id="player" contentPath="{dg.selectedItem.filepath}"
autoPlay="true" width="253" height="1" complete="movenext()"
change="{progress.setProgress(player.playheadTime, player.totalTime)}"/>
                        <mx:MediaController   id="mediacontrol" controllerPolicy="on" 
associatedDisplay="player"  width="100%" enabled="true"
activePlayControl="play" />

                        <mx:HBox>

                          <mx:Button label="Previous"
click="{dg.selectedIndex=dg.selectedIndex-1}"/>
                         <mx:Button  id="next" label="Next"
click="{dg.selectedIndex=dg.selectedIndex+1}"/>
                         <mx:HSlider id="volcontrol" width="100" maximum="100" minimum="0" 
change="{player.volume=volcontrol.value}" value="75" />
                      <mx:ProgressBar id="progress" mode="manual" minimum="0" 
complete="{dg.selectedIndex=dg.selectedIndex-1}"/>
                        </mx:HBox>
             </mx:VBox>
          </mx:ControlBar>

            </mx:Panel>
        </mx:HBox>
    </mx:Canvas>

</mx:Application>

--------------------------Actionscript--------------------------

import mx.managers.DragManager;
var selectedItem:Object;
var selectedItem1:Object;
function doDragEnter(event)      {
    event.handled="true";
}

function doDragExit(event) {
    event.target.hideDropFeedback();
}

function doDragOver(event) {
    event.target.showDropFeedback();

    if (Key.isDown(Key.CONTROL))
        event.action = "">
    else
        event.action = "">
}

function doDragDrop(event) {

    doDragExit(event);
    var items = event.dragSource.dataForFormat("items");
    var dest = event.target;
    var dropLoc = dest.getDropLocation()

    items.reverse()

    for(var i = 0; i < items.length; i++) {
        dest.addItemAt(dropLoc, items[i]);
    }
}

function doDragComplete(event) {
    doDragExit(event);
    var src = "">

    if (event.action == DragManager.MOVE) {

        var items = src.selectedIndices;

       items.sort(sortByNumber)            // If user selects the listitems in random
order, we first sort the array to have all the items in order
       items.reverse()                    // then we reverse the array. In list when
any item is removed, it decreases the index of the items below it.
                                    // so we remove the bottom most item
first.
        var s="";
        for(var i = 0; i < items.length; i++) {
            s=s+items[i]+" : ";
        }

        for(var i = 0; i < items.length; i++) {
            src.removeItemAt(items[i])
        }

    }
}

function sortByNumber(a, b) {
  return (a > b);
}

function movenext () {
  dg.selectedIndex=dg.selectedIndex+1
  //player.contentPath=model1.Music.Album.file[dg.selectedIndex];
  //mediacontrol.activePlayControl="pause";
  player.autoPlay=false;
}




Date: Sat, 11 Jun 2005 21:33:00 -0400
From: "JesterXL" <[EMAIL PROTECTED]>
Subject: Re: Digest Number 877

Check the docs for events you can register for.

The MediaPlayer has a "complete" event that'll trigger when the media is
done.  Have that play the next selected song when it fires.

----- Original Message -----
From: "Venkata Krishnan Natarajan" <[EMAIL PROTECTED]>
To: <flexcoders@yahoogroups.com>
Sent: Saturday, June 11, 2005 2:15 PM
Subject: RE: [flexcoders] Digest Number 877


Hi,

I'm a beginner to RIA development. I'm trying to develop a music player
using flex. Currently I load a list of songs in a datagrid. When the user
clicks an item, the media contoller and player plays the song. I would like
the player to automatically go to the next song in the grid after the song
is completed. Can anyone advise on how to approach this.

Thanks
Venkat

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/




Yahoo! Groups Links

Reply via email to