Skip to content

Commit

Permalink
* Ported to Haxe3
Browse files Browse the repository at this point in the history
* Adjusted OGG Player so it does not need to reload every 30 minutes (same in AAC).
  (So now the only codec forcing a reconnection from time to time is MP3).
* Added codec information to the tracking system (helps us to better choose next steps).
* Added Armenian Translation (thx. to Տեր-Գր.)
* Added Tatar Translation (thx. to Arslangali)
  • Loading branch information
fbricker committed Nov 3, 2013
1 parent fd32e32 commit 07b14cc
Show file tree
Hide file tree
Showing 35 changed files with 361 additions and 144 deletions.
21 changes: 17 additions & 4 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
v1.0b [2013-06-16]
v[1.2]
* Ported to Haxe3
* Adjusted OGG Player so it does not need to reload every 30 minutes (same in AAC).
(So now the only codec forcing a reconnection from time to time is MP3).
* Added codec information to the tracking system (helps us to better choose next steps).
* Added Armenian Translation (thx. to Տեր-Գր.)
* Added Tatar Translation (thx. to Arslangali)
* Added new Official and Comminity Skins.
* in progres...

v1.0b [2013-06-16]
* Added support for pure AAC streamings (AAC+V2 and FLV containers not supported yet).
* Refactored liveConnectionChecking all codecs supported.
* Fixed memory leak on OGG Streamings.
* Added support for requesting metadata on icecast streaming *with get parameters* (tnx to Allmoz https://github.com/Allmoz)
* Fixed bug on MRP.js (functions like MRP.stop(), MRP.play() and MRP.setVolume(...) are working fine again)
* Added support for requesting metadata on icecast streaming *with get parameters* (tnx to
Allmoz https://github.com/Allmoz)
* Fixed bug on MRP.js (functions like MRP.stop(), MRP.play() and MRP.setVolume(...) are
working fine again)
* Support for animated Skins (can use SWF instead of static images)
* Added Labels to Flash Buttons to help blind or print-impaired users using Screen Reader software (like JAWS).
* Added Labels to Flash Buttons to help blind or print-impaired users using Screen Reader
software (like JAWS).
* Added fallbackUrl option to the javascript MRP.js code.
* Fixed documentation of musesCallback function.
* Happy Father's Day!
Expand Down
6 changes: 4 additions & 2 deletions MetadataLoader.hx
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ class MetadataLoader {
if(counter>=delay && player.isPlaying()){
counter = 0;
var url:String=null;
url = switch(metadataSource) {
url = switch(metadataSource) {
case "icecast": player.getCurrentUrl().split("?")[0] + ".xspf";
case "streamtheworld": mUrl + "&" + Date.now().getTime();
case "shoutcast": StringTools.replace(player.getCurrentUrl(), ';', '');
default: null;
}
if(proxy!=null){
url=proxy+'?url='+StringTools.replace(url,':','%3A');
Expand All @@ -78,7 +79,8 @@ class MetadataLoader {
this.fileLoader.addEventListener(Event.COMPLETE, switch(metadataSource) {
case "icecast": loadIcecastEvent;
case "streamtheworld": loadStreamTheWorldEvent;
case "shoutcast": loadShoutcastEvent; } );
case "shoutcast": loadShoutcastEvent;
default: null; } );
fileLoader.load(urlRequest);
}

Expand Down
4 changes: 2 additions & 2 deletions MusesRadioPlayer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MusesRadioPlayer{
var reconnectTime : Int;

public static var SKIN:String = 'default';
public static var VERSION = "1.0b";
public static var VERSION = "1.2 beta";
public static var FPS:Int = 12;

// Kick things off
Expand Down Expand Up @@ -94,7 +94,7 @@ class MusesRadioPlayer{

ui.buildContextMenu();
switch (codec) {
case "ogg": player = new OggPlayer(ui, url, new Tracker(tracking), fallbackUrl, introUrl, reconnectTime);
case "ogg": player = new OggPlayer(ui, url, new Tracker(tracking), fallbackUrl, introUrl);
case "aac": player = new AacPlayer(ui, url, new Tracker(tracking), fallbackUrl, introUrl);
default: player = new Mp3Player(ui, url, new Tracker(tracking), fallbackUrl, introUrl, reconnectTime);
}
Expand Down
5 changes: 3 additions & 2 deletions MusesRadioPlayer.hxml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-swf9 muses.swf
-cp .
-swf ./muses.swf
-main MusesRadioPlayer
-swf-version 10.1
-swf-header 300:20:12:000000
-swf-lib Resource.swf
-swf-lib Resource.swf
56 changes: 0 additions & 56 deletions MusesRadioPlayer.hxproj

This file was deleted.

1 change: 1 addition & 0 deletions OGGSound.hx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class OGGSound extends flash.events.EventDispatcher {

public function new(){
super();
play_buffered = false;
}

public function stop(){
Expand Down
4 changes: 2 additions & 2 deletions OggPlayer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class OggPlayer extends Player {
org.xiph.fvorbis.FuncResidue._s_init();
}

public function new(ui:UI,url:String,tracker:Tracker,fallbackUrl:String,introUrl:String,reconnectTime:Int){
public function new(ui:UI,url:String,tracker:Tracker,fallbackUrl:String,introUrl:String){
init_statics();
super(ui,url,tracker,fallbackUrl,introUrl,reconnectTime);
super(ui,url,tracker,fallbackUrl,introUrl,0);
fileextension="ogg";
}

Expand Down
2 changes: 1 addition & 1 deletion Player.hx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class Player {
var url = getUrl();
// If there's a url
if (url != null){
tracker.track(getCurrentUrl(),true);
tracker.track(this,true);
// If no sound object, create one
if (soundObject == null){
request = new flash.net.URLRequest(url);
Expand Down
13 changes: 8 additions & 5 deletions Tracker.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Muses Radio Player - Radio Streaming player written in Haxe.
//
// Copyright (C) 2009-2012 Federico Bricker
// Copyright (C) 2009-2013 Federico Bricker
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand All @@ -27,24 +27,27 @@

class Tracker {
var enabled:Bool;
var tracked:Hash<Bool>;
var tracked:Map<String,Bool>;

public function new (enabled:Bool){
this.enabled=enabled;
tracked=new Hash<Bool>();
tracked=new Map<String,Bool>();
}

public function track(url:String,justOnce:Bool){
public function track(player:Player,justOnce:Bool){
// HERE IS THE CODE FOR TRACKING AT GOOGLE ANALYTICS
// TRACKING CAN BE EASLITY DISABLED BY PASSING tracking=false WITH THE FLASHVARS
// IF YOU WANT ACCESS TO TRACKING STATISTICS, JUST WRITE ME TO FBRCKER(AT)GMAIL.COM
// AND I'LL GIVO YOU FULL ACCESS TO THIS STATISTICS :)

var playerClass:String = Type.getClassName(Type.getClass(player));
var url:String = player.getCurrentUrl();

if(enabled && (!justOnce || !tracked.get(url))){
flash.Lib.getURL(new flash.net.URLRequest("javascript:
(function (){
ifrm = document.createElement('IFRAME');
ifrm.setAttribute('src', 'http://hosted.musesradioplayer.com/tracker/track.php?version="+MusesRadioPlayer.VERSION+"&url="+url+"&skin="+MusesRadioPlayer.SKIN+"');
ifrm.setAttribute('src', 'http://hosted.musesradioplayer.com/tracker/track.php?version="+MusesRadioPlayer.VERSION+"&url="+url+"&player="+playerClass+"&skin="+MusesRadioPlayer.SKIN+"');
ifrm.style.width = 1+'px';
ifrm.style.height = 1+'px';
ifrm.style.display = 'none';
Expand Down
2 changes: 1 addition & 1 deletion VolumeControlBase.hx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class VolumeControlBase extends flash.display.Sprite {
var vertDesp:Int;
var barStep:Int;
var barWidth:Int;
var bgColors:Array<Int>;
var bgColors:Array<UInt>;
var barColors:Array<Int>;
var spriteBar:flash.display.Sprite;
var firstDraw:Bool;
Expand Down
130 changes: 130 additions & 0 deletions aac/FLVSound.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
////////////////////////////////////////////////////////////////////////////////
//
// Muses Radio Player - Radio Streaming player written in Haxe.
//
// Copyright (C) 2009-2013 Federico Bricker
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// This Project was initially based on FOggPlayer by Bill Farmer. So
// my special thanks to him! :)
//
// Federico Bricker f bricker [at] gmail [dot] com.
//
////////////////////////////////////////////////////////////////////////////////

package aac;

import flash.display.Sprite;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.NetStatusEvent;
import flash.events.ProgressEvent;
import flash.Lib;
import flash.media.SoundTransform;
import flash.net.FileReference;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.net.NetStreamAppendBytesAction;
import flash.net.URLRequest;
import flash.net.URLStream;
import flash.utils.ByteArray;
import flash.utils.Timer;

class FLVSound extends flash.events.EventDispatcher {
var input : URLStream;
var nt : NetStream;
var syncOk : Bool;
var mustPlay : Bool;
var url : String;
var nc : NetConnection;
var contador:Int;

public function new(url:String) {
super();
this.url = url;
mustPlay = false;
nc = new NetConnection();
input = new URLStream();
input.addEventListener(flash.events.ProgressEvent.PROGRESS, convertStream);
input.addEventListener(flash.events.Event.COMPLETE, _on_complete);
input.addEventListener(flash.events.IOErrorEvent.IO_ERROR, _on_error);
input.addEventListener(flash.events.SecurityErrorEvent.SECURITY_ERROR, _on_security);
nc.connect(null);
nt = new NetStream(nc);
nt.useHardwareDecoder = true;
nt.backBufferTime = 1;
nt.bufferTime = 2;
nt.play(null);
nt.addEventListener("metadataReceived", function (e) { trace (e); } );
}

public function setBufferingTime(time:Float) {
nt.bufferTime = time;
}

function _on_complete(e : flash.events.Event) : Void {
if (hasEventListener(flash.events.Event.COMPLETE)) dispatchEvent(e);
}

function _on_error(e : flash.events.IOErrorEvent) : Void {
if (hasEventListener( flash.events.IOErrorEvent.IO_ERROR)) dispatchEvent(e);
}

function _on_security(e : flash.events.SecurityErrorEvent) : Void {
if (hasEventListener(flash.events.SecurityErrorEvent.SECURITY_ERROR)) dispatchEvent(e);
}

public function play() {
syncOk = false;
mustPlay = true;
input.load(new URLRequest(url));
}

public function stop() {
mustPlay = false;
nt.close();
input.removeEventListener(flash.events.ProgressEvent.PROGRESS, convertStream);
input.removeEventListener(flash.events.Event.COMPLETE, _on_complete);
input.removeEventListener(flash.events.IOErrorEvent.IO_ERROR, _on_error);
input.removeEventListener(flash.events.SecurityErrorEvent.SECURITY_ERROR, _on_security);
input.close();
nc.close();

adtsStripper = null;
nt = null;
nc = null;
input = null;
}

public function setVolume(vol:Float) {
nt.soundTransform = new SoundTransform(vol);
}

function convertStream( e : Event ) {
if (!mustPlay) return;

while(input.bytesAvailable >=8192){
var data : ByteArray = new ByteArray();
input.readBytes(data);
nt.appendBytes(data);
}
}

public function getProgress():Float {
return nt.time;
}

}
4 changes: 2 additions & 2 deletions internationalization/AbstractLanguage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
package internationalization;

class AbstractLanguage {
private var byText:Hash<String>;
private var byText:Map<String,String>;

public function new(){
byText=new Hash<String>();
byText=new Map<String,String>();
}

public function getText(key:String):String{
Expand Down
Loading

0 comments on commit 07b14cc

Please sign in to comment.