Package net.sphene.goim.rcp.media

Source Code of net.sphene.goim.rcp.media.MP3Media

/*
* GOIM - Gamers Own Instant Messenger
* Copyright (C) 2005 Herbert Poul (kahless@sphene.net / herbert.poul@gmail.com)
* http://goim.sphene.net
*
* 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
*/

package net.sphene.goim.rcp.media;

import java.io.BufferedInputStream;
import java.io.InputStream;


import net.sphene.goim.rcp.media.mp3.AudioDevice;
import net.sphene.goim.rcp.media.mp3.FactoryRegistry;
import net.sphene.goim.rcp.media.mp3.JavaLayerException;
import net.sphene.goim.rcp.media.mp3.Player;

public class MP3Media implements Media {
  protected InputStream is = null;
  protected Player player = null;

  private MP3Media() {
  }

  public MP3Media(InputStream is) {
    this.is = is;
  }
 
  public void run() {
    play();
  }

  public void play() {
    try {
      BufferedInputStream bin = new BufferedInputStream(is);
      AudioDevice dev = getAudioDevice();
      player = new Player(bin, dev);
      player.play();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 
  public void stop() {
    if (player != null) {
      player.close();
      player = null;
    }   
  }
 
  protected AudioDevice getAudioDevice()
    throws JavaLayerException {
    return FactoryRegistry.systemRegistry().createAudioDevice();
  }
 
}
TOP

Related Classes of net.sphene.goim.rcp.media.MP3Media

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.