diff --git a/core/movie.cpp b/core/movie.cpp index 8c7ffa5..9e017c4 100644 --- a/core/movie.cpp +++ b/core/movie.cpp @@ -21,7 +21,9 @@ class Movie::Private : m_url( url ), m_rotation( Rotation0 ), m_playMode( PlayOnce ), - m_showControls( false ) + m_device( 0 ), + m_showControls( false ), + m_autoPlay( false ) { } @@ -29,7 +31,9 @@ class Movie::Private QSize m_aspect; Rotation m_rotation; PlayMode m_playMode; + QIODevice *m_device; bool m_showControls : 1; + bool m_autoPlay : 1; }; Movie::Movie( const QString& fileName ) @@ -47,6 +51,16 @@ QString Movie::url() const return d->m_url; } +void Movie::setDevice( QIODevice *device ) +{ + d->m_device = device; +} + +QIODevice * Movie::device() const +{ + return d->m_device; +} + void Movie::setSize( const QSize &aspect ) { d->m_aspect = aspect; @@ -86,3 +100,14 @@ Movie::PlayMode Movie::playMode() const { return d->m_playMode; } + +void Movie::setAutoPlay( bool autoPlay ) +{ + d->m_autoPlay = autoPlay; +} + +bool Movie::autoPlay() const +{ + return d->m_autoPlay; +} + diff --git a/core/movie.h b/core/movie.h index f4b64e1..b26c321 100644 --- a/core/movie.h +++ b/core/movie.h @@ -15,6 +15,8 @@ #include +class QIODevice; + namespace Okular { /** @@ -52,6 +54,18 @@ class OKULAR_EXPORT Movie QString url() const; /** + * Sets the IO device for the movie. + * \optional + */ + void setDevice( QIODevice *device ); + + /** + * Returns the IO device for the movie. + * \optional + */ + QIODevice *device() const; + + /** * Sets the size for the movie. */ void setSize( const QSize &aspect ); @@ -91,6 +105,16 @@ class OKULAR_EXPORT Movie */ PlayMode playMode() const; + /** + * Sets whether to play the movie automatically + */ + void setAutoPlay( bool autoPlay ); + + /** + * Whether to play the movie automatically + */ + bool autoPlay() const; + private: class Private; Private* const d; diff --git a/generators/poppler/annots.cpp b/generators/poppler/annots.cpp index 2944b64..fc398ff 100644 --- a/generators/poppler/annots.cpp +++ b/generators/poppler/annots.cpp @@ -21,6 +21,7 @@ Q_DECLARE_METATYPE( Poppler::Annotation* ) extern Okular::Sound* createSoundFromPopplerSound( const Poppler::SoundObject *popplerSound ); extern Okular::Movie* createMovieFromPopplerMovie( const Poppler::MovieObject *popplerMovie ); +extern Okular::Movie* createMovieFromPopplerScreen( const Poppler::ScreenObject *popplerScreen ); static void disposeAnnotation( const Okular::Annotation *ann ) { @@ -69,6 +70,16 @@ Okular::Annotation* createAnnotationFromPopplerAnnotation( Poppler::Annotation * break; } + case Poppler::Annotation::AScreen: + { + Poppler::ScreenAnnotation * screenann = static_cast< Poppler::ScreenAnnotation * >( ann ); + Okular::MovieAnnotation * m = new Okular::MovieAnnotation(); + annotation = m; + + m->setMovie( createMovieFromPopplerScreen( screenann->screen() ) ); + + break; + } default: { // this is uber ugly but i don't know a better way to do it without introducing a poppler::annotation dependency on core diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp index 391d304..1070af3 100644 --- a/generators/poppler/generator_pdf.cpp +++ b/generators/poppler/generator_pdf.cpp @@ -45,6 +45,8 @@ #include +#include + #include "formfields.h" #include "popplerembeddedfile.h" @@ -151,6 +153,18 @@ Okular::Movie* createMovieFromPopplerMovie( const Poppler::MovieObject *popplerM return movie; } +Okular::Movie* createMovieFromPopplerScreen( const Poppler::ScreenObject *popplerScreen ) +{ + Poppler::MediaRendition *rendition = popplerScreen->action()->rendition(); + Okular::Movie *movie = new Okular::Movie( rendition->fileName() ); + movie->setDevice( rendition->streamDevice() ); + movie->setSize( rendition->size() ); + movie->setShowControls( rendition->showControls() ); + movie->setPlayMode( Okular::Movie::PlayOnce ); + movie->setAutoPlay( rendition->autoPlay() ); + return movie; +} + Okular::Action* createLinkFromPopplerLink(const Poppler::Link *popplerLink) { Okular::Action *link = 0; @@ -160,6 +174,7 @@ Okular::Action* createLinkFromPopplerLink(const Poppler::Link *popplerLink) const Poppler::LinkAction *popplerLinkAction; const Poppler::LinkSound *popplerLinkSound; const Poppler::LinkJavaScript *popplerLinkJS; + const Poppler::LinkRendition *popplerLinkRendition; Okular::DocumentViewport viewport; switch(popplerLink->linkType()) @@ -215,6 +230,10 @@ Okular::Action* createLinkFromPopplerLink(const Poppler::Link *popplerLink) } break; + case Poppler::Link::Rendition: + // not implemented + break; + case Poppler::Link::Movie: // not implemented break; diff --git a/ui/videowidget.cpp b/ui/videowidget.cpp index 2a48772..34bc405 100644 --- a/ui/videowidget.cpp +++ b/ui/videowidget.cpp @@ -88,23 +88,30 @@ void VideoWidget::Private::load() loaded = true; - QString url = anno->movie()->url(); - KUrl newurl; - if ( QDir::isRelativePath( url ) ) - { - newurl = document->currentDocument(); - newurl.setFileName( url ); - } - else - { - newurl = url; + if ( anno->movie()->device() ) + player->load( anno->movie()->device() ); + else { + QString url = anno->movie()->url(); + KUrl newurl; + if ( QDir::isRelativePath( url ) ) + { + newurl = document->currentDocument(); + newurl.setFileName( url ); + } + else + { + newurl = url; + } + if ( newurl.isLocalFile() ) + player->load( newurl.toLocalFile() ); + else + player->load( newurl ); } - if ( newurl.isLocalFile() ) - player->load( newurl.toLocalFile() ); - else - player->load( newurl ); seekSlider->setEnabled( true ); + + if (anno->movie()->autoPlay()) + q->play(); } void VideoWidget::Private::setupPlayPauseAction( PlayPauseMode mode )