2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef HTMLMediaElement_h
27 #define HTMLMediaElement_h
29 #include "HTMLElement.h"
30 #include "ExceptionCode.h"
31 #include <wtf/OwnPtr.h>
32 #include <wtf/PassRefPtr.h>
43 QRect
naturalSize() const { return QRect(); }
44 float duration() const { return 0; }
45 float rate() const { return 0; }
46 void setRate(float) { }
47 void setVolume(float) { }
48 float currentTime() const { return 0; }
49 float maxTimeSeekable() { return 0; }
50 float maxTimeBuffered() { return 0; }
53 class HTMLMediaElement
: public HTMLElement
{
55 HTMLMediaElement(Document
*);
56 virtual ~HTMLMediaElement();
58 virtual void attributeChanged(NodeImpl::Id attrId
);
60 virtual bool isVideo() const { return false; }
66 PassRefPtr
<MediaError
> error() const;
70 void setSrc(const String
&);
71 String
currentSrc() const;
73 enum NetworkState
{ EMPTY
, LOADING
, LOADED_METADATA
, LOADED_FIRST_FRAME
, LOADED
};
74 NetworkState
networkState() const;
75 float bufferingRate();
76 PassRefPtr
<TimeRanges
> buffered() const;
77 void load(ExceptionCode
&);
80 enum ReadyState
{ DATA_UNAVAILABLE
, CAN_SHOW_CURRENT_FRAME
, CAN_PLAY
, CAN_PLAY_THROUGH
};
81 ReadyState
readyState() const;
85 float currentTime() const;
86 void setCurrentTime(float, ExceptionCode
&);
87 float duration() const;
89 float defaultPlaybackRate() const;
90 void setDefaultPlaybackRate(float, ExceptionCode
&);
91 float playbackRate() const;
92 void setPlaybackRate(float, ExceptionCode
&);
93 PassRefPtr
<TimeRanges
> played() const;
94 PassRefPtr
<TimeRanges
> seekable() const;
96 bool autoplay() const;
97 void setAutoplay(bool b
);
98 void play(ExceptionCode
&);
99 void pause(ExceptionCode
&);
103 void setStart(float time
);
105 void setEnd(float time
);
106 float loopStart() const;
107 void setLoopStart(float time
);
108 float loopEnd() const;
109 void setLoopEnd(float time
);
110 unsigned playCount() const;
111 void setPlayCount(unsigned, ExceptionCode
&);
112 unsigned currentLoop() const;
113 void setCurrentLoop(unsigned);
116 bool controls() const;
117 void setControls(bool);
118 float volume() const;
119 void setVolume(float, ExceptionCode
&);
124 float getTimeOffsetAttribute(NodeImpl::Id name
, float valueOnError
) const;
125 void setTimeOffsetAttribute(NodeImpl::Id name
, float value
);
127 void checkIfSeekNeeded();
129 void setReadyState(ReadyState
);
133 void updatePlayState();
134 bool endedPlayback() const;
137 float m_defaultPlaybackRate
;
138 NetworkState m_networkState
;
139 ReadyState m_readyState
;
142 RefPtr
<MediaError
> m_error
;
145 bool m_loadedFirstFrame
;
148 unsigned m_currentLoop
;
155 float m_currentTimeDuringSeek
;
157 unsigned m_previousProgress
;
158 double m_previousProgressTime
;
159 bool m_sentStalledEvent
;
161 float m_bufferingRate
;
163 OwnPtr
<MediaPlayer
> m_player
;