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 java.net.URI;
19  import java.util.logging.Logger;
20  
21  import org.fourthline.cling.support.avtransport.lastchange.AVTransportVariable;
22  import org.fourthline.cling.support.model.AVTransport;
23  import org.fourthline.cling.support.model.TransportAction;
24  import org.fourthline.cling.support.model.TransportInfo;
25  import org.fourthline.cling.support.model.TransportState;
26  
27  /**
28   * @author Christian Bauer
29   */
30  public abstract class PausedPlay<T extends AVTransport> extends AbstractState<T>
31  {
32  
33      final private static Logger log = Logger.getLogger(PausedPlay.class.getName());
34  
35      public PausedPlay(T transport) {
36          super(transport);
37      }
38  
39      public void onEntry() {
40          log.fine("Setting transport state to PAUSED_PLAYBACK");
41          getTransport().setTransportInfo(
42                  new TransportInfo(
43                          TransportState.PAUSED_PLAYBACK,
44                          getTransport().getTransportInfo().getCurrentTransportStatus(),
45                          getTransport().getTransportInfo().getCurrentSpeed()
46                  )
47          );
48          getTransport().getLastChange().setEventedValue(
49                  getTransport().getInstanceId(),
50                  new AVTransportVariable.TransportState(TransportState.PAUSED_PLAYBACK),
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  
59      public TransportAction[] getCurrentTransportActions() {
60          return new TransportAction[] {
61                  TransportAction.Stop,
62                  TransportAction.Play
63          };
64      }
65  
66  }