File indexing completed on 2024-11-10 09:39:02
0001 /* 0002 * Copyright (C) 2009 Michael Howell <mhowell123@gmail.com>. 0003 * Parts copyright (C) 2007, 2008 Apple Inc. All rights reserved. 0004 * 0005 * Redistribution and use in source and binary forms, with or without 0006 * modification, are permitted provided that the following conditions 0007 * are met: 0008 * 1. Redistributions of source code must retain the above copyright 0009 * notice, this list of conditions and the following disclaimer. 0010 * 2. Redistributions in binary form must reproduce the above copyright 0011 * notice, this list of conditions and the following disclaimer in the 0012 * documentation and/or other materials provided with the distribution. 0013 * 0014 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 0015 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0016 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 0017 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 0018 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 0019 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 0020 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 0021 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 0022 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0023 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0024 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0025 */ 0026 0027 #ifndef render_media_h 0028 #define render_media_h 0029 0030 #include <phonon/videoplayer.h> 0031 #include <rendering/render_replaced.h> 0032 #include <html/HTMLMediaElement.h> 0033 0034 namespace khtml 0035 { 0036 0037 class MediaPlayer : public Phonon::VideoPlayer 0038 { 0039 Q_OBJECT 0040 public: 0041 inline MediaPlayer(Phonon::Category category, QWidget *parent = nullptr) : Phonon::VideoPlayer(category, parent) 0042 { 0043 } 0044 inline explicit MediaPlayer(QWidget *parent = nullptr) : Phonon::VideoPlayer(parent) {}; 0045 }; 0046 0047 class RenderMedia : public RenderWidget 0048 { 0049 Q_OBJECT 0050 public: 0051 const char *renderName() const override 0052 { 0053 return "RenderMedia"; 0054 } 0055 bool isMedia() const override 0056 { 0057 return true; 0058 } 0059 0060 void setPlayer(MediaPlayer *player); 0061 MediaPlayer *player() 0062 { 0063 return m_player; 0064 } 0065 const MediaPlayer *player() const 0066 { 0067 return m_player; 0068 } 0069 HTMLMediaElement *mediaElement() 0070 { 0071 return static_cast<HTMLMediaElement *>(RenderWidget::element()); 0072 } 0073 const HTMLMediaElement *mediaElement() const 0074 { 0075 return static_cast<const HTMLMediaElement *>(RenderWidget::element()); 0076 } 0077 0078 protected: 0079 bool eventFilter(QObject *, QEvent *) override; 0080 0081 private Q_SLOTS: 0082 void slotMetaDataChanged(); 0083 0084 private: 0085 RenderMedia(HTMLMediaElement *element); 0086 void layout() override; 0087 void updateFromElement() override; 0088 MediaPlayer *m_player; 0089 friend class HTMLMediaElement; 0090 }; 0091 0092 } //namespace 0093 0094 #endif