File indexing completed on 2024-04-28 04:48:39
0001 /* 0002 SPDX-FileCopyrightText: 2005 Max Howell <max.howell@methylblue.com> 0003 SPDX-FileCopyrightText: 2007 Ian Monroe <ian@monroe.nu> 0004 0005 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0006 */ 0007 0008 #ifndef DRAGONPLAYER_VIDEOWINDOW_H 0009 #define DRAGONPLAYER_VIDEOWINDOW_H 0010 0011 #include "codeine.h" 0012 0013 #include <QMultiMap> 0014 #include <QUrl> 0015 #include <QWidget> 0016 0017 #include <phonon/Global> 0018 #include <phonon/MediaSource> 0019 #include <phonon/ObjectDescription> 0020 #include <phonon/Path> 0021 0022 #include <Solid/Device> 0023 0024 class QActionGroup; 0025 class QTimer; 0026 0027 namespace Phonon 0028 { 0029 class VideoWidget; 0030 class AudioOutput; 0031 class MediaObject; 0032 class MediaController; 0033 class AudioDataOutput; 0034 } 0035 0036 namespace Dragon 0037 { 0038 class VideoWindow : public QWidget 0039 { 0040 Q_OBJECT 0041 0042 public: 0043 static VideoWindow *s_instance; 0044 0045 private: 0046 VideoWindow(const VideoWindow &); // disable 0047 VideoWindow &operator=(const VideoWindow &); // disable 0048 void eject(); 0049 0050 QTimer *m_cursorTimer; 0051 bool m_justLoaded; 0052 QActionGroup *m_subLanguages; 0053 QActionGroup *m_audioLanguages; 0054 QWidget *m_logo; 0055 bool m_isPreview; 0056 quint64 m_initialOffset; 0057 0058 Phonon::VideoWidget *m_vWidget; 0059 Phonon::AudioOutput *m_aOutput; 0060 Phonon::MediaObject *m_media; 0061 Phonon::MediaController *m_controller; 0062 Phonon::AudioDataOutput *m_aDataOutput; 0063 Phonon::Path m_audioPath; 0064 Phonon::Path m_audioDataPath; 0065 0066 friend class TheStream; 0067 0068 template<class ChannelDescription, class Func> 0069 void updateActionGroup(QActionGroup *channelActions, const QList<ChannelDescription> &availableChannels, Func actionSlot); 0070 0071 public: 0072 explicit VideoWindow(QWidget *parent); 0073 ~VideoWindow() override; 0074 0075 bool init(); 0076 0077 bool load(const QUrl &url); 0078 bool load(const QList<QUrl> &urls); 0079 bool play(qint64 = 0); 0080 bool resume(); 0081 bool playDvd(); 0082 bool playDisc(const Solid::Device &); 0083 bool isMuted(); 0084 bool isPreview(const bool &v = 0); 0085 void relativeSeek(qint64); 0086 0087 qint64 length() const; 0088 bool isDVD() const; 0089 0090 bool setupAnalyzer(QObject *analyzer); /// return whether setup was successful 0091 0092 /// stuff for dbus: 0093 qreal volume() const; 0094 void setVolume(qreal); 0095 QString urlOrDisc() const; 0096 QMultiMap<QString, QString> metaData() const; 0097 Phonon::MediaSource::Type mediaSourceType() const; 0098 bool isSeekable() const; 0099 qint32 tickInterval() const; 0100 //} 0101 0102 QWidget *newPositionSlider(); 0103 QWidget *newVolumeSlider(); 0104 void loadSettings(); 0105 0106 Phonon::State state() const; 0107 bool isActiveState() const; 0108 bool isActiveState(Phonon::State s) const; 0109 0110 /// Stuff to do with video and the video window/widget 0111 static const uint CURSOR_HIDE_TIMEOUT = 2000; 0112 0113 qint64 currentTime() const; 0114 int videoSetting(const QString &); 0115 0116 public Q_SLOTS: 0117 void pause(); 0118 void playPause(); 0119 void seek(qint64); 0120 void stop(); 0121 void stateChanged(Phonon::State, Phonon::State); 0122 void settingChanged(int); 0123 void mute(bool); 0124 0125 void toggleDVDMenu(); 0126 void showOSD(const QString &); 0127 void slotSetSubtitle(); 0128 void slotSetAudio(); 0129 void resetZoom(); 0130 0131 void prevChapter(); 0132 void nextChapter(); 0133 void tenPercentBack(); 0134 void tenPercentForward(); 0135 void tenSecondsBack(); 0136 void tenSecondsForward(); 0137 0138 void increaseVolume(); 0139 void decreaseVolume(); 0140 0141 bool canGoPrev() const; 0142 bool canGoNext() const; 0143 0144 protected: 0145 bool event(QEvent *e) override; 0146 void contextMenuEvent(QContextMenuEvent *event) override; 0147 void mouseDoubleClickEvent(QMouseEvent *) override; 0148 QSize sizeHint() const override; 0149 Phonon::State state(Phonon::State state) const; 0150 void setSubtitle(int channel); 0151 void setAudioChannel(int channel); 0152 private Q_SLOTS: 0153 void updateChannels(); 0154 void hideCursor(); 0155 Q_SIGNALS: 0156 void stateUpdated(const Phonon::State, const Phonon::State); 0157 void subChannelsChanged(QList<QAction *>); 0158 void audioChannelsChanged(QList<QAction *>); 0159 void tick(qint64); 0160 void currentSourceChanged(const Phonon::MediaSource); 0161 void totalTimeChanged(qint64); 0162 void mutedChanged(bool); 0163 void seekableChanged(bool); 0164 void metaDataChanged(); 0165 void hasVideoChanged(bool); 0166 void volumeChanged(qreal); 0167 void finished(); 0168 }; 0169 0170 // global function for general use by Dragon Player 0171 0172 // rearranged from previous non-static functions due to compiler warning 0173 static inline VideoWindow *engine() 0174 { 0175 return VideoWindow::s_instance; 0176 } 0177 static inline VideoWindow *videoWindow() 0178 { 0179 return VideoWindow::s_instance; 0180 } 0181 } 0182 0183 #endif