1 /* 2 * This file is part of libbluray 3 * Copyright (C) 2010 William Hahne 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library. If not, see 17 * <http://www.gnu.org/licenses/>. 18 */ 19 20 package org.videolan.media.content.playlist; 21 22 import java.awt.Component; 23 24 import org.bluray.media.AngleChangeEvent; 25 import org.bluray.media.AngleChangeListener; 26 import org.bluray.media.AngleControl; 27 import org.bluray.media.InvalidAngleException; 28 import org.videolan.BDJListeners; 29 import org.videolan.Libbluray; 30 import org.videolan.PlaylistInfo; 31 32 public class AngleControlImpl implements AngleControl { AngleControlImpl(Handler player)33 protected AngleControlImpl(Handler player) { 34 this.player = player; 35 } 36 getControlComponent()37 public Component getControlComponent() { 38 return null; 39 } 40 getCurrentAngle()41 public int getCurrentAngle() { 42 return Libbluray.getCurrentAngle(); 43 } 44 getAvailableAngles()45 public int getAvailableAngles() { 46 PlaylistInfo pi = player.getPlaylistInfo(); 47 if (pi == null) 48 return -1; 49 return pi.getAngleCount(); 50 } 51 selectDefaultAngle()52 public void selectDefaultAngle() { 53 Libbluray.selectAngle(1); 54 } 55 selectAngle(int angle)56 public void selectAngle(int angle) throws InvalidAngleException { 57 if (!Libbluray.selectAngle(angle)) 58 throw new InvalidAngleException(); 59 } 60 addAngleChangeListener(AngleChangeListener listener)61 public void addAngleChangeListener(AngleChangeListener listener) { 62 listeners.add(listener); 63 } 64 removeAngleChangeListener(AngleChangeListener listener)65 public void removeAngleChangeListener(AngleChangeListener listener) { 66 listeners.remove(listener); 67 } 68 onAngleChange(int angle)69 protected void onAngleChange(int angle) { 70 listeners.putCallback(new AngleChangeEvent(this, angle)); 71 } 72 73 private BDJListeners listeners = new BDJListeners(); 74 private Handler player; 75 } 76