Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added shuffling of playlist
  • Loading branch information
edvakf committed Feb 12, 2011
1 parent c3c197c commit 6984ba8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/VideoInfoView.mxml
Expand Up @@ -246,6 +246,7 @@
<mx:Button label="↓↑" left="53" bottom="5" id="button_reverse" click="playListReverseButtonClicked(event)" toolTip="このプレイリストの順番を逆順にします"/>
<mx:Button left="101" bottom="5" label="保存" click="playListSaveButtonClicked(event)" toolTip="このプレイリストの内容を保存します"/>
<mx:Button left="155" bottom="5" label="クリア" click="playListClearButtonClicked(event)" toolTip="このプレイリストを空にします"/>
<mx:Button left="213" bottom="5" label="Shuffle" id="button_shuffle" click="playListShuffleButtonClicked(event)" toolTip="このプレイリストをシャッフルします"/>
<mx:Label left="0" top="0" right="0" id="label_playListTitle" text="{label_playListTitle_dataProvider}"/>
</mx:Canvas>
<mx:Canvas label="タグ" width="100%" height="100%" id="canvas_Tag">
Expand Down
19 changes: 19 additions & 0 deletions src/org/mineap/NNDD/view/VideoInfoView.as
Expand Up @@ -1600,3 +1600,22 @@ private function playListReverseButtonClicked(event:Event):void{
playListProvider = tempArrayCollection;
}

private function playListShuffleButtonClicked(event:Event):void{
var tempArrayCollection:ArrayCollection = new ArrayCollection();

for each(var object:Object in playListProvider){
tempArrayCollection.addItem(object);
}

var i:int = tempArrayCollection.length;
while (--i) {
var j:int = Math.floor( Math.random() * (i + 1) );
if (i == j) continue;
var object:Object = tempArrayCollection.getItemAt(i);
tempArrayCollection.setItemAt( tempArrayCollection.getItemAt(j), i );
tempArrayCollection.setItemAt( object, j );
}

playListProvider = tempArrayCollection;
}

0 comments on commit 6984ba8

Please sign in to comment.