View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.support.avtransport.impl.state;
17  
18  import org.fourthline.cling.support.avtransport.lastchange.AVTransportVariable;
19  import org.fourthline.cling.support.model.AVTransport;
20  import org.fourthline.cling.support.model.SeekMode;
21  import org.fourthline.cling.support.model.TransportAction;
22  import org.fourthline.cling.support.model.TransportInfo;
23  import org.fourthline.cling.support.model.TransportState;
24  
25  import java.net.URI;
26  import java.util.logging.Logger;
27  
28  /**
29   * @author Christian Bauer
30   */
31  public abstract class Stopped<T extends AVTransport> extends AbstractState<T> {
32  
33      final private static Logger log = Logger.getLogger(Stopped.class.getName());
34  
35      public Stopped(T transport) {
36          super(transport);
37      }
38  
39      public void onEntry() {
40          log.fine("Setting transport state to STOPPED");
41          getTransport().setTransportInfo(
42                  new TransportInfo(
43                          TransportState.STOPPED,
44                          getTransport().getTransportInfo().getCurrentTransportStatus(),
45                          getTransport().getTransportInfo().getCurrentSpeed()
46                  )
47          );
48          getTransport().getLastChange().setEventedValue(
49                  getTransport().getInstanceId(),
50                  new AVTransportVariable.TransportState(TransportState.STOPPED),
51                  new AVTransportVariable.CurrentTransportActions(getCurrentTransportActions())
52          );
53      }
54  
55      public abstract Class<? extends AbstractState<?>> setTransportURI(URI uri, String metaData);
56      public abstract Class<? extends AbstractState<?>> stop();
57      public abstract Class<? extends AbstractState<?>> play(String speed);
58      public abstract Class<? extends AbstractState<?>> next();
59      public abstract Class<? extends AbstractState<?>> previous();
60      public abstract Class<? extends AbstractState<?>> seek(SeekMode unit, String target);
61  
62      public TransportAction[] getCurrentTransportActions() {
63          return new TransportAction[] {
64                  TransportAction.Stop,
65                  TransportAction.Play,
66                  TransportAction.Next,
67                  TransportAction.Previous,
68                  TransportAction.Seek
69          };
70      }
71  }