From: <to...@us...> - 2007-02-12 23:10:14
|
Revision: 45 http://techne-dev.svn.sourceforge.net/techne-dev/?rev=45&view=rev Author: tonit Date: 2007-02-12 15:10:12 -0800 (Mon, 12 Feb 2007) Log Message: ----------- Added Paths: ----------- sandbox/tonit/techne.audio/src/techne/audio/player/ sandbox/tonit/techne.audio/src/techne/audio/player/Activator.java sandbox/tonit/techne.audio/src/techne/audio/player/internal/ sandbox/tonit/techne.audio/src/techne/audio/player/internal/JavaZoomMusicPlayer.java Removed Paths: ------------- sandbox/tonit/techne.audio/src/techne/audio/Activator.java sandbox/tonit/techne.audio/src/techne/audio/BackgroundPlayer.java sandbox/tonit/techne.audio/src/techne/audio/PlayerService.java Deleted: sandbox/tonit/techne.audio/src/techne/audio/Activator.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/Activator.java 2007-02-12 05:00:13 UTC (rev 44) +++ sandbox/tonit/techne.audio/src/techne/audio/Activator.java 2007-02-12 23:10:12 UTC (rev 45) @@ -1,24 +0,0 @@ -package techne.audio; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; - -public class Activator implements BundleActivator { - - public void start(BundleContext ctx) throws Exception { - System.out.println("Audio ON"); - try { - System.out.println("Component header: " - + ctx.getBundle().getHeaders().get("Service-Component")); - - System.out.println("LogReader wired!"); - } catch (Exception e) { - System.out.println("Cannot wire to logreader"); - } - } - - public void stop(BundleContext arg0) throws Exception { - System.out.println("Audio OFF"); - } - -} Deleted: sandbox/tonit/techne.audio/src/techne/audio/BackgroundPlayer.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/BackgroundPlayer.java 2007-02-12 05:00:13 UTC (rev 44) +++ sandbox/tonit/techne.audio/src/techne/audio/BackgroundPlayer.java 2007-02-12 23:10:12 UTC (rev 45) @@ -1,33 +0,0 @@ -package techne.audio; - -import java.net.URL; -import java.net.URLConnection; - -import javazoom.jl.player.Player; - -public class BackgroundPlayer extends Thread { - private URL url; - - public BackgroundPlayer(URL url) { - System.out.println("backgroundplayer loading.."); - this.url = url; - } - - public void run() { - try { - URLConnection urlCon = url.openConnection(); - urlCon.getInputStream(); - Player pl = new Player(urlCon.getInputStream()); - - System.out.println("Start running backgroundplayer.."); - pl.play(); - System.out.println("Song should be finished now"); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - System.out.println(e.getMessage()); - throw new RuntimeException(e); - } - } - -} Deleted: sandbox/tonit/techne.audio/src/techne/audio/PlayerService.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/PlayerService.java 2007-02-12 05:00:13 UTC (rev 44) +++ sandbox/tonit/techne.audio/src/techne/audio/PlayerService.java 2007-02-12 23:10:12 UTC (rev 45) @@ -1,46 +0,0 @@ -package techne.audio; - -import java.net.URL; -import java.net.URLConnection; - -import javazoom.jl.player.Player; - -import org.osgi.service.component.ComponentContext; - -public class PlayerService extends Thread { - private ComponentContext context; - Player pl = null; - - public PlayerService() { - System.out.println("public constructor called!"); - } - - protected void activate(ComponentContext context) { - this.context = context; - start(); - } - - public void deactivate(ComponentContext context) throws Exception { - if (pl != null) pl.close(); - if (this.isAlive()) this.interrupt(); - System.out.println("Player Service is down"); - } - - public void run() { - try { - URL url = context.getBundleContext().getBundle().getResource("techne_hook.mp3"); - URLConnection urlCon = url.openConnection(); - urlCon.getInputStream(); - pl = new Player(urlCon.getInputStream()); - - System.out.println("Start running backgroundplayer.."); - pl.play(); - System.out.println("Song should be finished now"); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - System.out.println(e.getMessage()); - throw new RuntimeException(e); - } - } -} Copied: sandbox/tonit/techne.audio/src/techne/audio/player/Activator.java (from rev 8, sandbox/tonit/techne.audio/src/techne/audio/Activator.java) =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/player/Activator.java (rev 0) +++ sandbox/tonit/techne.audio/src/techne/audio/player/Activator.java 2007-02-12 23:10:12 UTC (rev 45) @@ -0,0 +1,24 @@ +package techne.audio.player; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + public void start(BundleContext ctx) throws Exception { + System.out.println("Audio ON"); + try { + System.out.println("Component header: " + + ctx.getBundle().getHeaders().get("Service-Component")); + + System.out.println("LogReader wired!"); + } catch (Exception e) { + System.out.println("Cannot wire to logreader"); + } + } + + public void stop(BundleContext arg0) throws Exception { + System.out.println("Audio OFF"); + } + +} Added: sandbox/tonit/techne.audio/src/techne/audio/player/internal/JavaZoomMusicPlayer.java =================================================================== --- sandbox/tonit/techne.audio/src/techne/audio/player/internal/JavaZoomMusicPlayer.java (rev 0) +++ sandbox/tonit/techne.audio/src/techne/audio/player/internal/JavaZoomMusicPlayer.java 2007-02-12 23:10:12 UTC (rev 45) @@ -0,0 +1,82 @@ +package techne.audio.player.internal; + +import org.osgi.service.component.ComponentContext; + +import techne.audio.player.MusicSource; +import techne.audio.player.PlayerControl; + +/** + * + * Currently it just supports a single track. Later it will accept mutiple + * tracks. Those track shoudl come from a MusicSource impl. Thus, the controls + * will likely to be extended (foward,backward) + * + * + * @author tmenzel + * + */ +public class JavaZoomMusicPlayer implements PlayerControl { + private JavaZoomPlayerThread thread; + private MusicSource musicSource; + private ComponentContext context; + + public JavaZoomMusicPlayer() { + } + + protected void activate(ComponentContext context) { + this.context = context; + // reference hopefully injected already? + if (musicSource != null) { + thread = new JavaZoomPlayerThread(); + thread.setMusicSource(musicSource); + } else { + System.out.println("There is no musicSource for some reason.. :-("); + } + } + + public void deactivate(ComponentContext context) throws Exception { + if (thread != null) { + thread.changeState(PlayerState.STATE_OFF); + thread.close(); + } + System.out.println("Player Service is down"); + } + + public void pause() { + thread.changeState(PlayerState.STATE_PAUSE); + } + + public void play() { + if (thread == null) { + thread = new JavaZoomPlayerThread(); + thread.setMusicSource(musicSource); + } + + if (thread != null) { + if (!thread.isAlive()) { + System.out.println("start player thread.."); + thread.start(); + } + thread.changeState(PlayerState.STATE_PLAY); + } + } + + public void stop() { + if (thread != null) { + thread.changeState(PlayerState.STATE_IDLE); + } + } + + public MusicSource getMusicSource() { + return musicSource; + } + + public void setMusicSource(MusicSource source) { + this.musicSource = source; + } + + public int getState() { + return thread.getCurrentPlayerState(); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |