summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/WMPSoundPlayer.java
blob: 9f5fadf57d38db33aaa686e4b3147ea032fe175b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package NET.worlds.scape;

import NET.worlds.console.WebControlImp;
import NET.worlds.network.URL;

public class WMPSoundPlayer extends SoundPlayer {
   protected DirectShow ds;
   protected boolean disabled;
   static int activeCount = 0;
   boolean playing = false;

   public WMPSoundPlayer(Sound owner) {
      super(owner);
      this.ds = new DirectShow();
   }

   public static boolean isActive() {
      return activeCount > 0;
   }

   @Override
   public boolean open(float volume, float stopDist, boolean atten, boolean pan) {
      return true;
   }

   @Override
   public void start(int repeat) {
      String megaURL = this.owner.getURL().toString();
      megaURL = WebControlImp.processURL(megaURL);
      this.ds.nOpen(URL.make(megaURL).unalias());
      activeCount++;
      this.ds.nPlay(repeat);
      this.playing = true;
   }

   @Override
   public boolean position(Point3Temp cam, Point3Temp obj, Point3Temp out, Point3Temp up) {
      return true;
   }

   @Override
   public int getState() {
      int nativeState = this.ds.nTick();
      return nativeState == 3 ? 0 : 1;
   }

   @Override
   public void stop() {
      this.ds.nStop();
      activeCount--;
      this.playing = false;
   }

   @Override
   public void close() {
      if (this.playing) {
         this.stop();
      }
   }

   @Override
   public boolean setVolume(float v) {
      return true;
   }
}