KHtml

HTMLMediaElement.h
1 /*
2  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3  * (C) 2009 Michael Howell <[email protected]>.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #ifndef HTMLMediaElement_h
28 #define HTMLMediaElement_h
29 
30 #include "html_elementimpl.h"
31 #include "HTMLElement.h"
32 #include "ExceptionCode.h"
33 #include <wtf/PassRefPtr.h>
34 #include <QPointer>
35 
36 namespace khtml
37 {
38 
39 class MediaError;
40 class TimeRanges;
41 class RenderMedia;
42 class MediaPlayer;
43 
44 class HTMLMediaElement : public HTMLElement
45 {
46 public:
47  HTMLMediaElement(Document *);
48  virtual ~HTMLMediaElement();
49 
50  void attach() override;
51  void close() override;
52 
53 // virtual void parseAttribute(AttributeImpl *token);
54  using DOM::ElementImpl::attributeChanged;
55  void attributeChanged(NodeImpl::Id attrId) override;
56 
57  virtual bool isVideo() const
58  {
59  return false;
60  }
61 
62  void scheduleLoad();
63 
64 // DOM API
65 // error state
66  PassRefPtr<MediaError> error() const;
67 
68 // network state
69  String src() const;
70  void setSrc(const String &);
71  String currentSrc() const;
72 
73  enum NetworkState { NETWORK_EMPTY, NETWORK_IDLE, NETWORK_LOADING, NETWORK_NO_SOURCE };
74  NetworkState networkState() const;
75  bool autobuffer() const;
76  void setAutobuffer(bool b);
77  PassRefPtr<TimeRanges> buffered() const;
78  void load(ExceptionCode &);
79  String canPlayType(String type);
80 
81 // ready state
82  enum ReadyState { HAVE_NOTHING, HAVE_METADATA, HAVE_CURRENT_DATA, HAVE_FUTURE_DATA, HAVE_ENOUGH_DATA };
83  ReadyState readyState() const;
84  bool seeking() const;
85 
86 // playback state
87  float currentTime() const;
88  void setCurrentTime(float, ExceptionCode &);
89  float startTime() const;
90  float duration() const;
91  bool paused() const;
92  float defaultPlaybackRate() const;
93  void setDefaultPlaybackRate(float, ExceptionCode &);
94  float playbackRate() const;
95  void setPlaybackRate(float, ExceptionCode &);
96  PassRefPtr<TimeRanges> played() const;
97  PassRefPtr<TimeRanges> seekable() const;
98  bool ended() const;
99  bool autoplay() const;
100  void setAutoplay(bool b);
101  bool loop() const;
102  void setLoop(bool b);
103  void play(ExceptionCode &);
104  void pause(ExceptionCode &);
105 
106 // controls
107  bool controls() const;
108  void setControls(bool);
109  float volume() const;
110  void setVolume(float, ExceptionCode &);
111  bool muted() const;
112  void setMuted(bool);
113 
114  String pickMedia();
115 
116 protected:
117  void checkIfSeekNeeded();
118 
119  void setReadyState(ReadyState);
120 
121 private:
122  void loadResource(String &url);
123  void updateLoadState();
124 
125  void updateVolume();
126  void updatePlayState();
127  bool endedPlayback() const;
128 
129 protected:
130  float m_defaultPlaybackRate;
131  NetworkState m_networkState;
132  ReadyState m_readyState;
133  String m_currentSrc;
134 
135  RefPtr<MediaError> m_error;
136 
137  bool m_begun;
138  bool m_loadedFirstFrame;
139  bool m_autoplaying;
140  bool m_autobuffer;
141 
142  float m_volume;
143  bool m_muted;
144 
145  bool m_paused;
146  bool m_seeking;
147 
148  float m_currentTimeDuringSeek;
149 
150  unsigned m_previousProgress;
151  double m_previousProgressTime;
152  bool m_sentStalledEvent;
153 
154  QPointer<MediaPlayer> m_player;
155 };
156 
157 } //namespace
158 
159 #endif
qreal volume()
This file is part of the HTML rendering engine for KDE.
KToggleAction * pause(const QObject *recvr, const char *slot, QObject *parent)
const QList< QKeySequence > & close()
QAction * load(const QObject *recvr, const char *slot, QObject *parent)
void error(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
void setVolume(qreal volume)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:03 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.