Stellarium  0.21.3
Public Slots
StelVideoMgr Class Reference

#include <StelVideoMgr.hpp>

Public Slots

virtual void init () Q_DECL_OVERRIDE
 
virtual void update (double deltaTime) Q_DECL_OVERRIDE
 Update the module with respect to the time. More...
 
void loadVideo (const QString &filename, const QString &id, const float x, const float y, const bool show, const float alpha)
 load a video from filename, assign an id for it for later reference. More...
 
void playVideo (const QString &id, const bool keepVisibleAtEnd=false)
 play video from current position. If keepLastFrame is true, video pauses at last frame.
 
void playVideoPopout (const QString &id, float fromX, float fromY, float atCenterX, float atCenterY, float finalSizeX, float finalSizeY, float popupDuration, bool frozenInTransition)
 Play a video which has previously been loaded with loadVideo() with a complex effect. More...
 
void pauseVideo (const QString &id)
 Pause video, keep it visible on-screen. More...
 
void stopVideo (const QString &id)
 Stop playing, resets video and hides video output window.
 
void dropVideo (const QString &id)
 Unload video from memory.
 
void seekVideo (const QString &id, const qint64 ms, bool pause=false)
 Seek a position in video id. More...
 
void setVideoXY (const QString &id, const float x, const float y, const bool relative=false)
 move upper left corner of video id to x, y. More...
 
void setVideoAlpha (const QString &id, const float alpha)
 sets opacity More...
 
void resizeVideo (const QString &id, float w=-1.0f, float h=-1.0f)
 set video size to width w and height h. More...
 
void showVideo (const QString &id, const bool show)
 show or hide video player More...
 
qint64 getVideoDuration (const QString &id) const
 returns duration (in milliseconds) of loaded video. More...
 
qint64 getVideoPosition (const QString &id) const
 returns current position (in milliseconds) of loaded video. More...
 
QSize getVideoResolution (const QString &id) const
 returns resolution (in pixels) of loaded video. Returned value may be invalid before video has been fully loaded.
 
int getVideoWidth (const QString &id) const
 returns native width (in pixels) of loaded video, or -1 in case of trouble.
 
int getVideoHeight (const QString &id) const
 returns native height (in pixels) of loaded video, or -1 in case of trouble.
 
void muteVideo (const QString &id, bool muteVideo=true)
 set mute state of video player More...
 
void setVideoVolume (const QString &id, int newVolume)
 set volume for video. Valid values are 0..100, values outside this range will be clamped.
 
int getVideoVolume (const QString &id) const
 return currently set volume (0..100) of media player, or -1 in case of some error.
 
bool isVideoPlaying (const QString &id) const
 returns whether video is currently playing. More...
 

Additional Inherited Members

- Public Types inherited from StelModule
enum  StelModuleSelectAction { AddToSelection, ReplaceSelection, RemoveFromSelection }
 Enum used when selecting objects to define whether to add to, replace, or remove from the existing selection list. More...
 
enum  StelModuleActionName {
  ActionDraw, ActionUpdate, ActionHandleMouseClicks, ActionHandleMouseMoves,
  ActionHandleKeys
}
 Define the possible action for which an order is defined. More...
 
- Public Member Functions inherited from StelModule
virtual void init ()=0
 Initialize itself. More...
 
virtual void deinit ()
 Called before the module will be delete, and before the openGL context is suppressed. More...
 
virtual QSettings * getSettings ()
 Return module-specific settings. More...
 
virtual void draw (StelCore *core)
 Execute all the drawing functions for this module. More...
 
virtual void update (double deltaTime)=0
 Update the module with respect to the time. More...
 
virtual QString getModuleVersion () const
 Get the version of the module, default is stellarium main version.
 
virtual QString getAuthorName () const
 Get the name of the module author.
 
virtual QString getAuthorEmail () const
 Get the email adress of the module author.
 
virtual void handleMouseClicks (class QMouseEvent *)
 Handle mouse clicks. More...
 
virtual void handleMouseWheel (class QWheelEvent *)
 Handle mouse wheel. More...
 
virtual bool handleMouseMoves (int x, int y, Qt::MouseButtons b)
 Handle mouse moves. More...
 
virtual void handleKeys (class QKeyEvent *e)
 Handle key events. More...
 
virtual bool handlePinch (qreal scale, bool started)
 Handle pinch gesture events. More...
 
virtual double getCallOrder (StelModuleActionName actionName) const
 Return the value defining the order of call for the given action For example if stars.callOrder[ActionDraw] == 10 and constellation.callOrder[ActionDraw] == 11, the stars module will be drawn before the constellations. More...
 
virtual bool configureGui (bool show=true)
 Detect or show the configuration GUI elements for the module. More...
 
- Protected Member Functions inherited from StelModule
class StelActionaddAction (const QString &id, const QString &groupId, const QString &text, QObject *target, const char *slot, const QString &shortcut="", const QString &altShortcut="")
 convenience methods to add an action (call to slot) to the StelActionMgr object. More...
 
class StelActionaddAction (const QString &id, const QString &groupId, const QString &text, const char *slot, const QString &shortcut="", const QString &altShortcut="")
 convenience methods to add an action (call to own slot) to the StelActionMgr object. More...
 
StelActionaddAction (const QString &id, const QString &groupId, const QString &text, QObject *contextObject, std::function< void()> lambda, const QString &shortcut="", const QString &altShortcut="")
 convenience methods to add an action (call to Lambda functor) to the StelActionMgr object. More...
 

Detailed Description

A scriptable way to show videos embedded in the screen. After experimental support with Qt4/Phonon library, this feature is back. Videos can be scaled, paused, placed and relocated (shifted) on screen. Setting opacity seems not to do much unless setting it to zero, the video is then simply invisible. Therefore smooth fading in/out or setting a semitransparent overlay does not work, but there is now an intro/end animation available: zooming out from a pixel position to a player frame position, and returning to that spot close to end of video playback.

However, support for multimedia content depends on the operating system, installed codecs, and completeness of the QtMultimedia system support, so some features or video formats may not work for you (test video and re-code it if necessary).

Linux notes

The listed functions have been tested and work on Ubuntu 15.04 with Qt5.4 with NVidia 9800M and Intel Core-i3/HD5500. You need to install GStreamer plugins. Most critical seems to be gstreamer0.10-ffmpeg from https://launchpad.net/~mc3man/+archive/ubuntu/gstffmpeg-keep, then it plays

Windows notes

According to https://wiki.qt.io/Qt_Multimedia, MinGW is limited to the decaying DirectShow platform plugin. The WMF platform plugin requires Visual Studio, so building with MSVC should provide better result. Some signals are not triggered under Windows, so we cannot use them, globally. There is partial success with MP4 files on MinGW, but also these are rendered badly. Often just shows an error on Windows/MinGW: DirectShowPlayerService::doRender: Unresolved error code 80040154 (number may differ, also seen: 80040228. Where is a list?) The formats tested on Windows are:

Mac OS X Notes

NOT TESTED ON A MAC! There is a critical difference (causing a crash!) between Win and Linux to either hide or not hide the player just after loading. Please somebody find out Mac behaviour.

QtMultimedia is a bit tricky to use: There seems to be no way to load a media file to analyze resolution or duration before starting its replay. This means, configuring player frames either require absolute frame coordinates, or triggering necessary configuration steps only after replay has started. We opted for the latter solution because it allows scaled but undistorted video frames which may also take current screen resolution into account.

Under unclear circumstances we also have a pair of messages:

Failed to start video surface due to main thread blocked.
Failed to start video surface

and non-appearing video frame, this seems to be https://bugreports.qt.io/browse/QTBUG-39567. This occurred on an Intel NUC5i3 with SSD, so loading the file should not be much of an issue.

To help in debugging scripts, this module can be quite verbose in the logfile if Stellarium is called with the command-line argument "--verbose".

Member Function Documentation

◆ getVideoDuration

qint64 StelVideoMgr::getVideoDuration ( const QString &  id) const
slot

This may return valid result only after playVideo() or pauseVideo() have been called. Returns -1 if video has not been analyzed yet. (loaded, but not started).

◆ getVideoPosition

qint64 StelVideoMgr::getVideoPosition ( const QString &  id) const
slot

This may return valid result only after playVideo() or pauseVideo() have been called. Returns -1 if video has not been analyzed yet. (loaded, but not started).

◆ isVideoPlaying

bool StelVideoMgr::isVideoPlaying ( const QString &  id) const
slot
Parameters
idname assigned during loadVideo().
Note
If video is not found, also returns false.

◆ loadVideo

void StelVideoMgr::loadVideo ( const QString &  filename,
const QString &  id,
const float  x,
const float  y,
const bool  show,
const float  alpha 
)
slot

If id is already in use, replace it. Prepare replay at upper-left corner x/ y in native resolution, decide whether to show (play) the video already, and set opacity alpha. If you want non-native resolution, load with show set to false, and use resizeVideo() and showVideo().

◆ muteVideo

void StelVideoMgr::muteVideo ( const QString &  id,
bool  muteVideo = true 
)
slot
Parameters
muteVideotrue to silence the video, false to hear audio.

◆ pauseVideo

void StelVideoMgr::pauseVideo ( const QString &  id)
slot

Calling playVideo() continues replay, calling seekVideo() can move to a different position.

◆ playVideoPopout

void StelVideoMgr::playVideoPopout ( const QString &  id,
float  fromX,
float  fromY,
float  atCenterX,
float  atCenterY,
float  finalSizeX,
float  finalSizeY,
float  popupDuration,
bool  frozenInTransition 
)
slot

The video appears to pop out from fromX/ fromY, grows within popupDuration to size finalSizeX/ finalSizeY, and shrinks back towards fromX/ fromY at the end during popdownDuration.

Parameters
idthe identifier used when loadVideo was called
fromXX position of starting point, counted from left of window. May be absolute (if >1) or relative (0<X<1)
fromYY position of starting point, counted from top of window. May be absolute (if >1) or relative (0<Y<1)
atCenterXX position of center of final video frame, counted from left of window. May be absolute (if >1) or relative (0<X<1)
atCenterYY position of center of final video frame, counted from top of window. May be absolute (if >1) or relative (0<Y<1)
finalSizeXX size of final video frame. May be absolute (if >1) or relative to window size (0<X<1). If -1, scale proportional from finalSizeY.
finalSizeYY size of final video frame. May be absolute (if >1) or relative to window size (0<Y<1). If -1, scale proportional from finalSizeX.
popupDurationduration of growing (start) / shrinking (end) transitions (seconds)
frozenInTransitiontrue if video should be paused during growing/shrinking transition.

◆ resizeVideo

void StelVideoMgr::resizeVideo ( const QString &  id,
float  w = -1.0f,
float  h = -1.0f 
)
slot

Use w=-1 or h=-1 for autoscale from the other dimension, or use w=h=-1 for native size of video. if w or h are <=1, the size is relative to screen dimensions. This should be the preferred use, because it allows the development of device-independent scripts. When native resolution is unknown at the time you call this, it will be evaluated at the next update() after resolution becomes known. Autoscaling uses viewport dimensions at the time of calling, so resizing the Stellarium window will not resize the video frame during replay.

◆ seekVideo

void StelVideoMgr::seekVideo ( const QString &  id,
const qint64  ms,
bool  pause = false 
)
slot

Pause the video playing if pause=true.

Note
This may not work if video has not been fully loaded. Better wait a second before proceeding after loadVideo(), and call seekVideo(., ., false); pauseVideo(.);

◆ setVideoAlpha

void StelVideoMgr::setVideoAlpha ( const QString &  id,
const float  alpha 
)
slot
Parameters
alphaopacity for the video (0=transparent, ... 1=fully opaque).
Note
if alpha is 0, also showVideo(id, true) cannot show the video.

◆ setVideoXY

void StelVideoMgr::setVideoXY ( const QString &  id,
const float  x,
const float  y,
const bool  relative = false 
)
slot

If x or y are <1, this is relative to screen size!

◆ showVideo

void StelVideoMgr::showVideo ( const QString &  id,
const bool  show 
)
slot
Parameters
idname given during loadVideo()
showtrue to show, false to hide

◆ update

virtual void StelVideoMgr::update ( double  deltaTime)
virtualslot

This allows the special effects in playVideoPopout(), and may evaluate things like video resolution when they become available.

Parameters
deltaTimethe time increment in second since last call.