1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_SLIDESHOW_ANIMATIONAUDIONODE_HXX
25 #define INCLUDED_SLIDESHOW_ANIMATIONAUDIONODE_HXX
26 
27 #include "basecontainernode.hxx"
28 #include "soundplayer.hxx"
29 #include "com/sun/star/animations/XAnimationNode.hpp"
30 #include "com/sun/star/animations/XAudio.hpp"
31 
32 namespace slideshow {
33 namespace internal {
34 
35 /** Audio node.
36 
37     This animation node contains an audio effect. Duration and
38     start/stop behavior is affected by the referenced audio
39     file.
40 */
41 class AnimationAudioNode : public BaseNode, public AnimationEventHandler
42 {
43 public:
44     AnimationAudioNode(
45         ::com::sun::star::uno::Reference<
46         ::com::sun::star::animations::XAnimationNode> const& xNode,
47         ::boost::shared_ptr<BaseContainerNode> const& pParent,
48         NodeContext const& rContext );
49 
50 protected:
51     virtual void dispose();
52 
53 private:
54     virtual void activate_st();
55     virtual void deactivate_st( NodeState eDestState );
56     virtual bool hasPendingAnimation() const;
57 
58     /// overridden, because we need to deal with STOPAUDIO commands
59     virtual bool handleAnimationEvent( const AnimationNodeSharedPtr& rNode );
60 
61 private:
62     ::com::sun::star::uno::Reference<
63         ::com::sun::star::animations::XAudio >  mxAudioNode;
64     ::rtl::OUString                             maSoundURL;
65     mutable SoundPlayerSharedPtr                mpPlayer;
66 
67     void createPlayer() const;
68     void resetPlayer() const;
69 };
70 
71 } // namespace internal
72 } // namespace slideshow
73 
74 #endif /* INCLUDED_SLIDESHOW_ANIMATIONAUDIONODE_HXX */
75