flexPartyPlayer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/Gemfile +6 -0
  2. data/README +45 -0
  3. data/lib/corelib-08.30.2007.swc +0 -0
  4. data/lib/flexPartyPlayer.rb +42 -0
  5. data/lib/flexunit-08.30.2007.swc +0 -0
  6. data/sample.json +1 -0
  7. data/script/destroy +14 -0
  8. data/script/flex_compile +2 -0
  9. data/script/generate +14 -0
  10. data/src/FlexPlayer.mxml +34 -0
  11. data/src/assets/app_icons/icon_128.png +0 -0
  12. data/src/cc/varga/mvc/ApplicationContext.as +120 -0
  13. data/src/cc/varga/mvc/commands/data/LoadArtistDataCommand.as +61 -0
  14. data/src/cc/varga/mvc/commands/playlist/AddItemToPlaylist.as +13 -0
  15. data/src/cc/varga/mvc/commands/playlist/LoadPlaylistCommand.as +109 -0
  16. data/src/cc/varga/mvc/commands/system/DrawPlaylist.as +40 -0
  17. data/src/cc/varga/mvc/commands/system/Shutdown.as +51 -0
  18. data/src/cc/varga/mvc/commands/system/Startup.as +57 -0
  19. data/src/cc/varga/mvc/commands/video/AddVideoCommand.as +55 -0
  20. data/src/cc/varga/mvc/events/appBar/AppBarEvent.as +16 -0
  21. data/src/cc/varga/mvc/events/blipfm/feedloader/FeedLoaderEvent.as +17 -0
  22. data/src/cc/varga/mvc/events/controllers/ControllersEvent.as +59 -0
  23. data/src/cc/varga/mvc/events/menu/MenuEvent.as +13 -0
  24. data/src/cc/varga/mvc/events/player/PlayerEvent.as +29 -0
  25. data/src/cc/varga/mvc/events/playlist/PlaylistEvent.as +16 -0
  26. data/src/cc/varga/mvc/events/playlist/PlaylistURLEvent.as +57 -0
  27. data/src/cc/varga/mvc/events/playlist/controller/PlaylistControllerEvent.as +59 -0
  28. data/src/cc/varga/mvc/events/search/SearchEvent.as +17 -0
  29. data/src/cc/varga/mvc/events/serveradmin/ServerAdminEvent.as +15 -0
  30. data/src/cc/varga/mvc/events/sound/SoundEvent.as +16 -0
  31. data/src/cc/varga/mvc/events/system/SystemEvent.as +24 -0
  32. data/src/cc/varga/mvc/models/data/AppDataModel.as +17 -0
  33. data/src/cc/varga/mvc/models/player/PlayerModel.as +76 -0
  34. data/src/cc/varga/mvc/models/playlist/PlaylistModel.as +118 -0
  35. data/src/cc/varga/mvc/models/sound/ISound.as +12 -0
  36. data/src/cc/varga/mvc/models/sound/SoundModel.as +284 -0
  37. data/src/cc/varga/mvc/models/sound/SoundModelPlayer.as +8 -0
  38. data/src/cc/varga/mvc/services/KeyboardControl.as +60 -0
  39. data/src/cc/varga/mvc/views/blipfm/feedloader/FeedLoader.mxml +34 -0
  40. data/src/cc/varga/mvc/views/blipfm/feedloader/FeedLoaderMediator.as +68 -0
  41. data/src/cc/varga/mvc/views/controllers/Controllers.mxml +36 -0
  42. data/src/cc/varga/mvc/views/controllers/ControllersMediator.as +107 -0
  43. data/src/cc/varga/mvc/views/infoDisplay/InfoDisplay.mxml +20 -0
  44. data/src/cc/varga/mvc/views/infoDisplay/InfoDisplayMediator.as +51 -0
  45. data/src/cc/varga/mvc/views/menu/Menu.mxml +28 -0
  46. data/src/cc/varga/mvc/views/menu/MenuMediator.as +30 -0
  47. data/src/cc/varga/mvc/views/player/PlayerItem.mxml +11 -0
  48. data/src/cc/varga/mvc/views/player/PlayerWindow.mxml +73 -0
  49. data/src/cc/varga/mvc/views/player/PlayerWindowMediator.as +136 -0
  50. data/src/cc/varga/mvc/views/playlist/Playlist.mxml +22 -0
  51. data/src/cc/varga/mvc/views/playlist/PlaylistMediator.as +117 -0
  52. data/src/cc/varga/mvc/views/playlist/PlaylistStates.as +10 -0
  53. data/src/cc/varga/mvc/views/playlistItem/PlaylistItem.mxml +94 -0
  54. data/src/cc/varga/mvc/views/playlistItem/PlaylistItemMediator.as +87 -0
  55. data/src/cc/varga/mvc/views/playlistManager/PlaylistManager.mxml +7 -0
  56. data/src/cc/varga/mvc/views/playlistManager/PlaylistManagerMediator.as +15 -0
  57. data/src/cc/varga/mvc/views/playlisturl/PlaylistURL.mxml +41 -0
  58. data/src/cc/varga/mvc/views/playlisturl/PlaylistURLMediator.as +87 -0
  59. data/src/cc/varga/mvc/views/playlisturl/controller/PlaylistController.mxml +37 -0
  60. data/src/cc/varga/mvc/views/playlisturl/controller/PlaylistControllerMediator.as +79 -0
  61. data/src/cc/varga/mvc/views/search/Search.mxml +26 -0
  62. data/src/cc/varga/mvc/views/search/SearchMediator.as +31 -0
  63. data/src/cc/varga/mvc/views/server/administration/ServerAdmin.mxml +26 -0
  64. data/src/cc/varga/mvc/views/server/administration/ServerAdminMediator.as +51 -0
  65. data/src/cc/varga/mvc/views/visualisation/Visualisation.mxml +8 -0
  66. data/src/cc/varga/mvc/views/visualisation/VisualisationMediator.as +51 -0
  67. data/src/cc/varga/utils/URLHelper.as +52 -0
  68. data/src/cc/varga/utils/logging/Logger.as +94 -0
  69. data/src/com/automatastudios/audio/audiodecoder/AudioDecoder.as +84 -0
  70. data/src/com/automatastudios/audio/audiodecoder/decoders/AudioInfo.as +52 -0
  71. data/src/com/automatastudios/audio/audiodecoder/decoders/IDecoder.as +13 -0
  72. data/src/com/automatastudios/audio/audiodecoder/decoders/OggVorbisDecoder.as +221 -0
  73. data/src/com/automatastudios/audio/audiodecoder/decoders/WAVDecoder.as +325 -0
  74. data/src/com/automatastudios/audio/audiodecoder/events/AudioDecoderEvent.as +13 -0
  75. data/src/com/automatastudios/data/riff/RIFFChunkInfo.as +6 -0
  76. data/src/com/automatastudios/data/riff/RIFFParser.as +175 -0
  77. data/src/libs/appinf/appinf.json +0 -0
  78. data/src/libs/appinf/config.json +0 -0
  79. data/src/libs/appinf/sample.json +1 -0
  80. data/src/libs/appinf/server.json +0 -0
  81. data/src/nl/flexcoders/controls/YouTubePlayer.as +317 -0
  82. data/test/Test-app.xml +40 -0
  83. data/test/Test.mxml +35 -0
  84. data/views/jukebox.haml +30 -0
  85. metadata +157 -0
@@ -0,0 +1,17 @@
1
+ package cc.varga.mvc.models.data
2
+ {
3
+ import org.robotlegs.mvcs.Actor;
4
+ import flash.utils.Dictionary;
5
+
6
+ public class AppDataModel extends Actor
7
+ {
8
+
9
+ public var artistList : Dictionary = new Dictionary;
10
+
11
+ public function AppDataModel()
12
+ {
13
+ super();
14
+ }
15
+
16
+ }
17
+ }
@@ -0,0 +1,76 @@
1
+ package cc.varga.mvc.models.player
2
+ {
3
+ import cc.varga.mvc.events.player.PlayerEvent;
4
+ import cc.varga.mvc.models.sound.ISound;
5
+ import cc.varga.mvc.views.player.PlayerWindow;
6
+
7
+ import mx.collections.ArrayCollection;
8
+
9
+ import org.robotlegs.mvcs.*;
10
+
11
+ public class PlayerModel extends Actor implements ISound
12
+ {
13
+ [Bindable]
14
+ private var currentPlayList : ArrayCollection = new ArrayCollection();
15
+
16
+ private var window : PlayerWindow = new PlayerWindow();
17
+
18
+ private var currentItem : uint = 0;
19
+
20
+ public function listlength():uint{
21
+ return currentPlayList.source.length;
22
+ }
23
+
24
+ public function addItemToPlaylist(json:Object):void{
25
+ playlist.addItem(json);
26
+ dispatch(new PlayerEvent(PlayerEvent.ITEM_ADD_TO_PLAYLIST));
27
+ }
28
+
29
+ public function getCurrentItem():Object{
30
+ return playlist.getItemAt(currentItem);
31
+ }
32
+
33
+ public function getNextItem():Object{
34
+ currentItem++;
35
+ if(currentItem > currentPlayList.length){
36
+ currentItem = 0;
37
+ }
38
+ return playlist.getItemAt(currentItem);
39
+ }
40
+
41
+ public function getPrevItem():Object{
42
+ currentItem--;
43
+ if(currentItem < 0){
44
+ currentItem = 0;
45
+ }
46
+ return playlist.getItemAt(currentItem);
47
+ }
48
+
49
+ public function removeItemByID(id : int):void{
50
+ currentPlayList.removeItemAt(id);
51
+ }
52
+
53
+ public function removeItemByObj(json:Object):void{
54
+
55
+ for(var i:uint=0; i <= currentPlayList.length; i++){
56
+
57
+ var item : Object = currentPlayList.getItemAt(i);
58
+
59
+ if(item["_id"] == json["_id"]){
60
+ removeItemByID(i);
61
+ }
62
+
63
+ }
64
+
65
+ }
66
+
67
+ public function get playlist():ArrayCollection{
68
+ return currentPlayList;
69
+ }
70
+
71
+ public function get lengthPlaylist():uint{
72
+ return currentPlayList.length;
73
+ }
74
+
75
+ }
76
+ }
@@ -0,0 +1,118 @@
1
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2
+ //
3
+ //Authors: Franics Varga
4
+ //eMail: fv@varga-multimedia.com
5
+ //homepage: http://www.varga-multimedia.com
6
+ //
7
+ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8
+ //<a href='http://creativecommons.org/licenses/by-nc-sa/3.0/'>Creative Commons License<a\>
9
+ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10
+ //
11
+ //You are free:
12
+ //
13
+ //to Share — to copy, distribute and transmit the work
14
+ //to Remix — to adapt the work
15
+ //Under the following conditions:
16
+ //
17
+ //Attribution — You must attribute the work in the manner specified by the author or licensor
18
+ //(but not in any way that suggests that they endorse you or your use of the work).
19
+ //
20
+ //Noncommercial — You may not use this work for commercial purposes.
21
+ //
22
+ //Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
23
+ //
24
+ //With the understanding that:
25
+ //
26
+ //Waiver — Any of the above conditions can be waived if you get permission from the copyright holder.
27
+ //Public Domain — Where the work or any of its elements is in the public domain under applicable law, that status is in no way affected by the license.
28
+ //Other Rights — In no way are any of the following rights affected by the license:
29
+ //
30
+ //Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations; The author's moral rights;
31
+ //
32
+ //Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights.
33
+ //Notice — For any reuse or distribution, you must make clear to others the license terms of this work.
34
+ //The best way to do this is with a link to this web page.
35
+ //
36
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37
+ package cc.varga.mvc.models.playlist
38
+ {
39
+ import cc.varga.mvc.models.sound.ISound;
40
+ import cc.varga.mvc.events.playlist.*;
41
+ import cc.varga.utils.logging.Logger;
42
+ import com.adobe.serialization.json.*;
43
+
44
+ import mx.collections.ArrayCollection;
45
+ import mx.rpc.events.FaultEvent;
46
+ import mx.rpc.events.ResultEvent;
47
+ import mx.rpc.http.mxml.HTTPService;
48
+
49
+ import org.robotlegs.mvcs.*;
50
+
51
+ public class PlaylistModel extends Actor implements ISound
52
+ {
53
+
54
+ [Bindable]
55
+ private var _playlistObj : ArrayCollection = new ArrayCollection();
56
+ private var searchText : String;
57
+
58
+ public var playListURL :String = "";
59
+ public var currentItem : uint = 0;
60
+
61
+ public function set playlistObj(value : Array):void{
62
+ _playlistObj.source = value;
63
+ }
64
+
65
+ public function getItems():Array{
66
+ return _playlistObj.source;
67
+ }
68
+
69
+ public function getNextItem():Object{
70
+ currentItem++;
71
+ if(currentItem >= _playlistObj.length){
72
+ currentItem = 0;
73
+ }
74
+
75
+ return _playlistObj.getItemAt(currentItem);
76
+ }
77
+
78
+ public function getPrevItem():Object{
79
+ currentItem--;
80
+ if(currentItem <= 0){
81
+ currentItem = 0;
82
+ }
83
+
84
+ return _playlistObj.getItemAt(currentItem);
85
+ }
86
+
87
+ public function getCurrentItem():Object{
88
+ return _playlistObj.getItemAt(currentItem);
89
+ }
90
+
91
+ public function listlength():uint{
92
+ return _playlistObj.source.length;
93
+ }
94
+
95
+ public function search(value : String):void{
96
+ this.searchText = value;
97
+ var http : HTTPService = new HTTPService();
98
+ http.addEventListener(FaultEvent.FAULT, onSerachFault);
99
+ http.addEventListener(ResultEvent.RESULT, onSearchResult);
100
+ http.method = "POST";
101
+ http.url = "http://aludose/web/search.json";
102
+
103
+ http.send( {"query":value} );
104
+ }
105
+
106
+ private function onSearchResult(event : ResultEvent):void{
107
+ playlistObj = JSON.decode(event.result.toString()) as Array;
108
+ dispatch(new PlaylistURLEvent(PlaylistURLEvent.PLAYLIST_DISPLAYED));
109
+ }
110
+
111
+ private function onSerachFault(event : FaultEvent):void{
112
+
113
+ }
114
+
115
+ public function toString():String{ return "cc.varga.mvc.models.playlist.PlaylistModel"}
116
+ }
117
+
118
+ }
@@ -0,0 +1,12 @@
1
+ package cc.varga.mvc.models.sound
2
+ {
3
+ public interface ISound
4
+ {
5
+
6
+ function getCurrentItem():Object
7
+ function getNextItem():Object
8
+ function getPrevItem():Object
9
+ function listlength():uint
10
+
11
+ }
12
+ }
@@ -0,0 +1,284 @@
1
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2
+ //
3
+ //Authors: Franics Varga
4
+ //eMail: fv@varga-multimedia.com
5
+ //homepage: http://www.varga-multimedia.com
6
+ //
7
+ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8
+ //<a href='http://creativecommons.org/licenses/by-nc-sa/3.0/'>Creative Commons License<a\>
9
+ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10
+ //
11
+ //You are free:
12
+ //
13
+ //to Share — to copy, distribute and transmit the work
14
+ //to Remix — to adapt the work
15
+ //Under the following conditions:
16
+ //
17
+ //Attribution — You must attribute the work in the manner specified by the author or licensor
18
+ //(but not in any way that suggests that they endorse you or your use of the work).
19
+ //
20
+ //Noncommercial — You may not use this work for commercial purposes.
21
+ //
22
+ //Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
23
+ //
24
+ //With the understanding that:
25
+ //
26
+ //Waiver — Any of the above conditions can be waived if you get permission from the copyright holder.
27
+ //Public Domain — Where the work or any of its elements is in the public domain under applicable law, that status is in no way affected by the license.
28
+ //Other Rights — In no way are any of the following rights affected by the license:
29
+ //
30
+ //Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations; The author's moral rights;
31
+ //
32
+ //Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights.
33
+ //Notice — For any reuse or distribution, you must make clear to others the license terms of this work.
34
+ //The best way to do this is with a link to this web page.
35
+ //
36
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37
+ package cc.varga.mvc.models.sound
38
+ {
39
+ import cc.varga.mvc.events.player.PlayerEvent;
40
+ import cc.varga.mvc.models.playlist.PlaylistModel;
41
+ import cc.varga.utils.logging.Logger;
42
+
43
+ import com.automatastudios.audio.audiodecoder.AudioDecoder;
44
+ import com.automatastudios.audio.audiodecoder.decoders.OggVorbisDecoder;
45
+
46
+ import flash.events.Event;
47
+ import flash.events.IOErrorEvent;
48
+ import flash.events.SampleDataEvent;
49
+ import flash.media.Sound;
50
+ import flash.media.SoundChannel;
51
+ import flash.media.Video;
52
+ import flash.net.NetConnection;
53
+ import flash.net.NetStream;
54
+ import flash.net.URLRequest;
55
+ import flash.net.URLStream;
56
+ import flash.system.System;
57
+
58
+ import mx.controls.Alert;
59
+
60
+ import org.robotlegs.mvcs.*;
61
+
62
+ public class SoundModel extends Actor
63
+ {
64
+
65
+ [Inject]
66
+ public var playlistModel : PlaylistModel;
67
+
68
+ public static const MP3 : String = "mp3";
69
+ public static const OGG : String = "ogg";
70
+ private static const BUFFER_SIZE:uint = 8192;
71
+
72
+ private var soundChannel : SoundChannel = new SoundChannel();
73
+ private var sound : Sound = new Sound();
74
+ private var decoder : AudioDecoder = new AudioDecoder();
75
+ private var soundURL : String;
76
+ private var contentURL : String;
77
+ private var currentCT : String;
78
+ private var _player : String;
79
+ private var currentPlaylist : ISound;
80
+
81
+ public var currentJSONObj : Object = new Object();
82
+
83
+ public function set player(value:String):void{
84
+ player = value;
85
+ }
86
+
87
+ public function setCurrentJSONObj(json : Object):void{
88
+
89
+ clearSound();
90
+
91
+ Logger.tracing("set current json object", this.toString());
92
+
93
+ playSound(json);
94
+
95
+ }
96
+
97
+ private function playSound(playObj:Object):void{
98
+
99
+ if(playObj != null){
100
+ currentJSONObj = playObj;
101
+ if(playObj['video_id']){
102
+ Logger.tracing("Is a youtube video", this.toString());
103
+ var event : PlayerEvent = new PlayerEvent(PlayerEvent.PLAY_YOUTUBE_VIDEO);
104
+ event.youtubeVideoID = playObj['video_id'] as String;
105
+ eventDispatcher.dispatchEvent(event);
106
+ }else{
107
+ checkFileType();
108
+ }
109
+
110
+ }else{
111
+ Alert.show("Something is wrong hit the developer FLEX!", "Error");
112
+ }
113
+
114
+ }
115
+
116
+ private function clearSound():void{
117
+
118
+ Logger.tracing("Clear all sound", this.toString());
119
+
120
+ soundChannel.stop();
121
+ soundChannel = null;
122
+ soundChannel = new SoundChannel();
123
+ sound = null;
124
+ sound = new Sound();
125
+ decoder = null;
126
+ decoder = new AudioDecoder();
127
+
128
+ System.gc();
129
+
130
+ }
131
+
132
+ public function playPlaylist(playlist:ISound):void{
133
+
134
+ clearSound();
135
+
136
+ currentPlaylist = playlist;
137
+
138
+ soundChannel.addEventListener(Event.SOUND_COMPLETE, onItemComplete);
139
+ sound.addEventListener(Event.COMPLETE, onItemComplete);
140
+ sound.addEventListener(Event.SOUND_COMPLETE, onItemComplete);
141
+ decoder.addEventListener(Event.COMPLETE, onItemComplete);
142
+ decoder.addEventListener(Event.SOUND_COMPLETE, onItemComplete);
143
+
144
+ if(currentPlaylist.listlength() > 0){
145
+ playSound(currentPlaylist.getCurrentItem());
146
+ }else{
147
+ Alert.show("Playlist is null", "Error");
148
+ }
149
+
150
+ }
151
+
152
+ private function onItemComplete(event : *):void{
153
+
154
+ Logger.tracing("Item Complete from Playlist", this.toString());
155
+
156
+ clearSound();
157
+
158
+ soundChannel.addEventListener(Event.SOUND_COMPLETE, onItemComplete);
159
+ sound.addEventListener(Event.COMPLETE, onItemComplete);
160
+ sound.addEventListener(Event.SOUND_COMPLETE, onItemComplete);
161
+ decoder.addEventListener(Event.COMPLETE, onItemComplete);
162
+ decoder.addEventListener(Event.SOUND_COMPLETE, onItemComplete);
163
+
164
+ setCurrentJSONObj(currentPlaylist.getNextItem());
165
+
166
+ }
167
+
168
+ private function checkFileType(playTo : String = ""):void{
169
+
170
+ Logger.tracing("check file type", this.toString());
171
+
172
+ for (var item : * in currentJSONObj){
173
+
174
+ if(item == "_attachments"){
175
+ for(var att : * in currentJSONObj[item]){
176
+ var cont:String = att;
177
+
178
+ if(cont.lastIndexOf(".ogg") >= 1){
179
+ Logger.tracing("Play OGG File", this.toString());
180
+ contentURL = cont;
181
+ currentCT = "ogg";
182
+ loadOGGFile();
183
+ break;
184
+ }else if(cont.indexOf(".mp3") >= 1){
185
+ Logger.tracing("Play Mp3 File", this.toString());
186
+ contentURL = cont;
187
+ currentCT = "mp3"
188
+ loadMp3File();
189
+ break;
190
+ }
191
+
192
+ }
193
+ }
194
+
195
+ }
196
+
197
+ }
198
+
199
+ private function loadmp4():void{
200
+
201
+ var connect_nc:NetConnection = new NetConnection();
202
+ connect_nc.connect(null);
203
+ var stream_ns:NetStream = new NetStream(connect_nc);
204
+ var video : Video = new Video();
205
+ video.attachNetStream(stream_ns);
206
+
207
+ stream_ns.play("D:\_Random\video.mp4");
208
+ }
209
+
210
+ private function loadMp3File():void{
211
+
212
+ sound.addEventListener(Event.COMPLETE, onLoadComplete_mp3);
213
+ sound.addEventListener(SampleDataEvent.SAMPLE_DATA, onSoundData);
214
+ sound.addEventListener(IOErrorEvent.IO_ERROR, onIOError_mp3);
215
+ //sound.load(new URLRequest("http://localserver:5984/musiclib/737fa73795ac1bff9f3c1145ccacd16c/04-gentleman_reg--when_heroes_change_professions-oma.mp3"));
216
+ sound.load(new URLRequest("http://aludose/" + currentJSONObj["_id"] + "/" + contentURL));
217
+ soundChannel = sound.play();
218
+
219
+ }
220
+
221
+ private function onSoundData(event : SampleDataEvent):void{
222
+ trace(event);
223
+ }
224
+
225
+ private function onLoadComplete_mp3(event : Event):void{
226
+ Logger.tracing("mp3 file complete", this.toString());
227
+ }
228
+
229
+ private function onIOError_mp3(event : IOErrorEvent):void{
230
+
231
+ }
232
+
233
+ private function loadOGGFile():void{
234
+ decoder.addEventListener(Event.INIT, onDecoderInit);
235
+ /*decoder.addEventListener(IOErrorEvent.IO_ERROR, onDecoderIOError);
236
+ decoder.addEventListener(Event.COMPLETE, onComplete);
237
+
238
+ soundChannel.addEventListener(Event.SOUND_COMPLETE, onComplete);*/
239
+
240
+ var oggStream : URLStream = new URLStream();
241
+
242
+ decoder.load(oggStream, OggVorbisDecoder, BUFFER_SIZE);
243
+ oggStream.load(new URLRequest("http://aludose/" + currentJSONObj["_id"] + "/" + contentURL));
244
+ Logger.tracing("Play File: " + "http://aludose/" + currentJSONObj["_id"] + "/" + contentURL, this.toString());
245
+ }
246
+
247
+ private function onComplete(event : Event):void{
248
+ Logger.tracing("OGG File Complete: " + event + " || Target: " + event.currentTarget, this.toString());
249
+ clearSound();
250
+ }
251
+
252
+ private function onDecoderInit(event : Event):void{
253
+ soundChannel = decoder.play();
254
+ Logger.tracing("Init OGG Decoder", this.toString());
255
+ }
256
+
257
+ private function onDecoderIOError(event : Event):void{
258
+ Logger.tracing("IO Decoder Error", this.toString());
259
+ }
260
+
261
+ public function pause():void{
262
+ soundChannel.stop();
263
+ }
264
+
265
+ public function stop():void{
266
+ clearSound();
267
+ }
268
+
269
+ public function next():void{
270
+ setCurrentJSONObj(currentPlaylist.getNextItem());
271
+ }
272
+
273
+ public function prev():void{
274
+ setCurrentJSONObj(currentPlaylist.getPrevItem() );
275
+ }
276
+
277
+ private function onSoundComplete(event : Event):void{
278
+
279
+ }
280
+
281
+ public function toString():String{ return "cc.varga.mvc.models.SoundModel"}
282
+ }
283
+
284
+ }
@@ -0,0 +1,8 @@
1
+ package cc.varga.mvc.models.sound
2
+ {
3
+ public class SoundModelPlayer
4
+ {
5
+ public static const PLAYER : String = "player";
6
+ public static const ITEM : String = "item";
7
+ }
8
+ }
@@ -0,0 +1,60 @@
1
+ package cc.varga.mvc.services
2
+ {
3
+ import cc.varga.mvc.events.player.PlayerEvent;
4
+ import cc.varga.mvc.models.playlist.PlaylistModel;
5
+ import cc.varga.utils.logging.Logger;
6
+
7
+ import com.automatastudios.audio.audiodecoder.AudioDecoder;
8
+ import com.automatastudios.audio.audiodecoder.decoders.OggVorbisDecoder;
9
+
10
+ import flash.events.KeyboardEvent;
11
+ import flash.events.MouseEvent;
12
+ import flash.events.Event;
13
+ import flash.events.IOErrorEvent;
14
+ import flash.events.SampleDataEvent;
15
+ import flash.media.Sound;
16
+ import flash.media.SoundChannel;
17
+ import flash.media.Video;
18
+ import flash.net.NetConnection;
19
+ import flash.net.NetStream;
20
+ import flash.net.URLRequest;
21
+ import flash.net.URLStream;
22
+ import flash.system.System;
23
+
24
+ import mx.controls.Alert;
25
+
26
+ import org.robotlegs.mvcs.*;
27
+
28
+
29
+ public class AppMediator extends Mediator
30
+ {
31
+
32
+
33
+ public function listen() :void{
34
+
35
+ contextView.addEventListener(MouseEvent.CLICK, clickHandler);
36
+
37
+ contextView.addEventListener(KeyboardEvent.KEY_DOWN,keyPressed);
38
+ }
39
+
40
+ private function clickHandler(event:MouseEvent):void {
41
+
42
+ //stage.focus = contextView;
43
+
44
+ }
45
+
46
+
47
+
48
+ private function keyPressed(evt:KeyboardEvent):void{
49
+
50
+ if(evt.ctrlKey && evt.keyCode == 65)
51
+
52
+ trace("CTRL A is pressed");
53
+
54
+ if(evt.ctrlKey && evt.keyCode == 66)
55
+
56
+ trace("CTRL B is pressed");
57
+
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
3
+ xmlns:s="library://ns.adobe.com/flex/spark"
4
+ xmlns:mx="library://ns.adobe.com/flex/halo"
5
+ xmlns:feedloader="cc.varga.mvc.views.blipfm.feedloader.*"
6
+ xmlns:loaderURL="cc.varga.mvc.views.blipfm.feedloader.loaderURL.*">
7
+
8
+ <s:layout><s:VerticalLayout/></s:layout>
9
+
10
+ <fx:Script>
11
+ <![CDATA[
12
+ import cc.varga.mvc.events.blipfm.feedloader.FeedLoaderEvent;
13
+ protected function load_clickHandler(event:MouseEvent):void
14
+ {
15
+ var feedEvent : FeedLoaderEvent = new FeedLoaderEvent(FeedLoaderEvent.LOAD_FEED);
16
+ feedEvent.blipNick = nick.text;
17
+ dispatchEvent(feedEvent);
18
+ }
19
+ ]]>
20
+ </fx:Script>
21
+
22
+
23
+ <s:Group width="100%" height="100%">
24
+ <s:layout><s:HorizontalLayout/></s:layout>
25
+ <s:Label text="Nickname: " fontSize="14" height="25" verticalAlign="middle"/>
26
+ <s:TextInput id="nick" fontSize="14" width="100%" height="25" />
27
+ <s:Button id="load" label="Load" width="50" height="25" click="load_clickHandler(event)" />
28
+ </s:Group>
29
+
30
+ <s:Group id="playlistContainer" width="100%" height="100%">
31
+ <s:layout><s:VerticalLayout/></s:layout>
32
+ </s:Group>
33
+
34
+ </s:Group>
@@ -0,0 +1,68 @@
1
+ package cc.varga.mvc.views.blipfm.feedloader
2
+ {
3
+ import cc.varga.mvc.events.blipfm.feedloader.FeedLoaderEvent;
4
+ import cc.varga.mvc.events.system.SystemEvent;
5
+ import cc.varga.utils.logging.Logger;
6
+
7
+ import com.adobe.serialization.json.*;
8
+
9
+ import mx.collections.ArrayCollection;
10
+ import mx.rpc.events.FaultEvent;
11
+ import mx.rpc.events.ResultEvent;
12
+ import mx.rpc.http.mxml.HTTPService;
13
+
14
+ import org.robotlegs.mvcs.*;
15
+
16
+ public class FeedLoaderMediator extends Mediator
17
+ {
18
+
19
+ [Inject]
20
+ public var view : FeedLoader;
21
+
22
+ public function FeedLoaderMediator()
23
+ {
24
+ super();
25
+ }
26
+
27
+ override public function onRegister():void{
28
+
29
+ Logger.tracing("FeedLoaderMediator onRegister", this.toString());
30
+
31
+ eventMap.mapListener(view, FeedLoaderEvent.LOAD_FEED, onFeedLoad);
32
+
33
+ }
34
+
35
+ private function onFeedLoad(event : FeedLoaderEvent):void{
36
+
37
+ Logger.tracing("onFeed Load", this.toString());
38
+
39
+ var httpService : HTTPService = new HTTPService();
40
+ httpService.method = "POST";
41
+ httpService.addEventListener(FaultEvent.FAULT, onFault);
42
+ httpService.addEventListener(ResultEvent.RESULT, onResult);
43
+ httpService.url = "http://aludose/web/blip/" + event.blipNick + ".json";
44
+ httpService.send();
45
+
46
+ }
47
+
48
+ private function onFault(event : FaultEvent):void{
49
+ Logger.tracing("Fault " + event.message, "");
50
+ }
51
+
52
+ private function onResult(event : ResultEvent):void{
53
+ Logger.tracing("Result " + event, "");
54
+
55
+ var jsonObj : Object = JSON.decode(event.result.toString());
56
+
57
+ var sysEvent : SystemEvent = new SystemEvent(SystemEvent.DRAW_PLAYLIST);
58
+ sysEvent.sourcePlaylist = jsonObj as ArrayCollection;
59
+ dispatch(sysEvent);
60
+
61
+ }
62
+
63
+ public function toString():String{
64
+ return "cc.varga.mvc.views.blipfm.feedloader.FeedLoaderContext";
65
+ }
66
+
67
+ }
68
+ }