gtkmm: Gtk::MediaFile Class Reference

Open media files for use in GTK. More...

#include <gtkmm/mediafile.h>

Inheritance diagram for Gtk::MediaFile:

Public Member Functions

 MediaFile (MediaFile&& src) noexcept
 
MediaFileoperator= (MediaFile&& src) noexcept
 
 ~MediaFile () noexcept override
 
GtkMediaFile* gobj ()
 Provides access to the underlying C GObject. More...

 
const GtkMediaFile* gobj () const
 Provides access to the underlying C GObject. More...

 
GtkMediaFile* gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...

 
void clear ()
 Resets the media file to be empty. More...

 
void set_filename (const std::string& filename)
 This is a utility function that converts the given filename to a Gio::File and calls set_file(). More...

 
void set_resource (const std::string& resource_path)
 This is a utility function that converts the given resource_path to a Gio::File and calls set_file(). More...

 
void set_file (const Glib::RefPtr< Gio::File >& file)
 If any file is still playing, stop playing it. More...

 
Glib::RefPtr< Gio::Fileget_file ()
 Returns the file that self is currently playing from. More...

 
Glib::RefPtr< const Gio::Fileget_file () const
 Returns the file that self is currently playing from. More...

 
void set_input_stream (const Glib::RefPtr< Gio::InputStream >& stream)
 If anything is still playing, stop playing it. More...

 
Glib::RefPtr< Gio::InputStreamget_input_stream ()
 Returns the stream that self is currently playing from. More...

 
Glib::RefPtr< const Gio::InputStreamget_input_stream () const
 Returns the stream that self is currently playing from. More...

 
Glib::PropertyProxy< Glib::RefPtr< Gio::File > > property_file ()
 The file being played back or nullptr if not playing a file. More...

 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::File > > property_file () const
 The file being played back or nullptr if not playing a file. More...

 
Glib::PropertyProxy< Glib::RefPtr< Gio::InputStream > > property_input_stream ()
 The stream being played back or nullptr if not playing a stream, like when playing a file. More...

 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::InputStream > > property_input_stream () const
 The stream being played back or nullptr if not playing a stream, like when playing a file. More...

 
- Public Member Functions inherited from Gtk::MediaStream
 MediaStream (MediaStream&& src) noexcept
 
MediaStreamoperator= (MediaStream&& src) noexcept
 
 ~MediaStream () noexcept override
 
GtkMediaStream* gobj ()
 Provides access to the underlying C GObject. More...

 
const GtkMediaStream* gobj () const
 Provides access to the underlying C GObject. More...

 
GtkMediaStream* gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...

 
bool is_prepared () const
 Returns whether the stream has finished initializing and existence of audio and video is known. More...

 
Glib::Error get_error () const
 If the stream is in an error state, returns the GError explaining that state. More...

 
bool has_audio () const
 Returns whether the stream has audio. More...

 
bool has_video () const
 Returns whether the stream has video. More...

 
void play ()
 Starts playing the stream. More...

 
void pause ()
 Pauses playback of the stream. More...

 
bool get_playing () const
 Return whether the stream is currently playing. More...

 
void set_playing (bool playing=true)
 Starts or pauses playback of the stream. More...

 
bool get_ended () const
 Returns whether the streams playback is finished. More...

 
gint64 get_timestamp () const
 Returns the current presentation timestamp in microseconds. More...

 
gint64 get_duration () const
 Gets the duration of the stream. More...

 
bool is_seekable () const
 Checks if a stream may be seekable. More...

 
bool is_seeking () const
 Checks if there is currently a seek operation going on. More...

 
void seek (gint64 timestamp)
 Start a seek operation on self to timestamp. More...

 
bool get_loop () const
 Returns whether the stream is set to loop. More...

 
void set_loop (bool loop=true)
 Sets whether the stream should loop, ie restart playback from the beginning instead of stopping at the end. More...

 
bool get_muted () const
 Returns whether the audio for the stream is muted. More...

 
void set_muted (bool muted=true)
 Sets whether the audio stream should be muted. More...

 
double get_volume () const
 Returns the volume of the audio for the stream. More...

 
void set_volume (double volume)
 Sets the volume of the audio stream. More...

 
void realize (const Glib::RefPtr< Gdk::Surface >& surface)
 Called by users to attach the media stream to a Gdk::Surface they manage. More...

 
void unrealize (const Glib::RefPtr< Gdk::Surface >& surface)
 Undoes a previous call to realize() and causes the stream to release all resources it had allocated from surface. More...

 
void prepared (bool has_audio, bool has_video, bool seekable, gint64 duration)
 Called by Gtk::MediaStream implementations to advertise the stream being ready to play and providing details about the stream. More...

 
void unprepared ()
 Resets a given media stream implementation. More...

 
void update (gint64 timestamp)
 Media stream implementations should regularly call this function to update the timestamp reported by the stream. More...

 
void ended ()
 Pauses the media stream and marks it as ended. More...

 
void seek_success ()
 Ends a seek operation started via GtkMediaStream.seek() successfully. More...

 
void seek_failed ()
 Ends a seek operation started via GtkMediaStream.seek() as a failure. More...

 
void set_error (const Glib::Error& error)
 Sets self into an error state. More...

 
Glib::PropertyProxy< bool > property_prepared ()
 Whether the stream has finished initializing and existence of audio and video is known. More...

 
Glib::PropertyProxy_ReadOnly< bool > property_prepared () const
 Whether the stream has finished initializing and existence of audio and video is known. More...

 
Glib::PropertyProxy_ReadOnly< Glib::Errorproperty_error () const
 nullptr for a properly working stream or the GError that the stream is in. More...

 
Glib::PropertyProxy_ReadOnly< bool > property_has_audio () const
 Whether the stream contains audio. More...

 
Glib::PropertyProxy_ReadOnly< bool > property_has_video () const
 Whether the stream contains video. More...

 
Glib::PropertyProxy< bool > property_playing ()
 Whether the stream is currently playing. More...

 
Glib::PropertyProxy_ReadOnly< bool > property_playing () const
 Whether the stream is currently playing. More...

 
Glib::PropertyProxy_ReadOnly< bool > property_ended () const
 Set when playback has finished. More...

 
Glib::PropertyProxy_ReadOnly< gint64 > property_timestamp () const
 The current presentation timestamp in microseconds. More...

 
Glib::PropertyProxy_ReadOnly< gint64 > property_duration () const
 The stream's duration in microseconds or 0 if unknown. More...

 
Glib::PropertyProxy_ReadOnly< bool > property_seekable () const
 Set unless the stream is known to not support seeking. More...

 
Glib::PropertyProxy_ReadOnly< bool > property_seeking () const
 Set while a seek is in progress. More...

 
Glib::PropertyProxy< bool > property_loop ()
 Try to restart the media from the beginning once it ended. More...

 
Glib::PropertyProxy_ReadOnly< bool > property_loop () const
 Try to restart the media from the beginning once it ended. More...

 
Glib::PropertyProxy< bool > property_muted ()
 Whether the audio stream should be muted. More...

 
Glib::PropertyProxy_ReadOnly< bool > property_muted () const
 Whether the audio stream should be muted. More...

 
Glib::PropertyProxy< double > property_volume ()
 Volume of the audio stream. More...

 
Glib::PropertyProxy_ReadOnly< double > property_volume () const
 Volume of the audio stream. More...

 
- Public Member Functions inherited from Glib::Object
 Object (const Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&src) noexcept
 
Objectoperator= (Object &&src) noexcept
 
void * get_data (const QueryQuark &key)
 
void set_data (const Quark &key, void *data)
 
void set_data (const Quark &key, void *data, DestroyNotify notify)
 
void remove_data (const QueryQuark &quark)
 
void * steal_data (const QueryQuark &quark)
 
Glib::RefPtr< Glib::Objectwrap (GObject *object, bool take_copy=false)
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (const ObjectBase &)=delete
 
void set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
 
void get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
 
void set_property (const Glib::ustring &property_name, const PropertyType &value)
 
void get_property (const Glib::ustring &property_name, PropertyType &value) const
 
PropertyType get_property (const Glib::ustring &property_name) const
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot)
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, sigc::slot< void()> &&slot)
 
void freeze_notify ()
 
void thaw_notify ()
 
virtual void reference () const
 
virtual void unreference () const
 
GObject * gobj ()
 
const GObject * gobj () const
 
GObject * gobj_copy () const
 
- Public Member Functions inherited from sigc::trackable
 trackable () noexcept
 
 trackable (const trackable &src) noexcept
 
 trackable (trackable &&src) noexcept
 
 ~trackable ()
 
void add_destroy_notify_callback (notifiable *data, func_destroy_notify func) const
 
void notify_callbacks ()
 
trackableoperator= (const trackable &src)
 
trackableoperator= (trackable &&src) noexcept
 
void remove_destroy_notify_callback (notifiable *data) const
 
- Public Member Functions inherited from Gdk::Paintable
 Paintable (Paintable&& src) noexcept
 
Paintableoperator= (Paintable&& src) noexcept
 
 ~Paintable () noexcept override
 
GdkPaintable* gobj ()
 Provides access to the underlying C GObject. More...

 
const GdkPaintable* gobj () const
 Provides access to the underlying C GObject. More...

 
void snapshot (const Glib::RefPtr< Gdk::Snapshot >& snapshot, double width, double height)
 Snapshots the given paintable with the given width and height at the current (0,0) offset of the snapshot. More...

 
Glib::RefPtr< const Paintableget_current_image () const
 Gets an immutable paintable for the current contents displayed by paintable. More...

 
Flags get_flags () const
 Get flags for the paintable. More...

 
int get_intrinsic_width () const
 Gets the preferred width the paintable would like to be displayed at. More...

 
int get_intrinsic_height () const
 Gets the preferred height the paintable would like to be displayed at. More...

 
double get_intrinsic_aspect_ratio () const
 Gets the preferred aspect ratio the paintable would like to be displayed at. More...

 
void compute_concrete_size (double specified_width, double specified_height, double default_width, double default_height, double& concrete_width, double& concrete_height) const
 Applies the sizing algorithm outlined in https://drafts.csswg.org/css-images-3/#default-sizing to the given paintable. More...

 
void invalidate_contents ()
 Called by implementations of Gdk::Paintable to invalidate their contents. More...

 
void invalidate_size ()
 Called by implementations of Gdk::Paintable to invalidate their size. More...

 
Glib::SignalProxy< void()> signal_invalidate_contents ()
 
Glib::SignalProxy< void()> signal_invalidate_size ()
 
- Public Member Functions inherited from Glib::Interface
 Interface ()
 
 Interface (Interface &&src) noexcept
 
Interfaceoperator= (Interface &&src) noexcept
 
 Interface (const Glib::Interface_Class &interface_class)
 
 Interface (GObject *castitem)
 
 ~Interface () noexcept override
 
 Interface (const Interface &)=delete
 
Interfaceoperator= (const Interface &)=delete
 
GObject * gobj ()
 
const GObject * gobj () const
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...

 
static Glib::RefPtr< MediaFilecreate ()
 Creates a new empty media file. More...

 
static Glib::RefPtr< MediaFilecreate_for_filename (const std::string& filename)
 This is a utility function that converts the given filename to a Gio::File and calls new_for_file(). More...

 
static Glib::RefPtr< MediaFilecreate_for_resource (const std::string& resource_path)
 This is a utility function that converts the given resource to a Gio::File and calls new_for_file(). More...

 
static Glib::RefPtr< MediaFilecreate (const Glib::RefPtr< Gio::File >& file)
 Creates a new media file to play file. More...

 
static Glib::RefPtr< MediaFilecreate (const Glib::RefPtr< Gio::InputStream >& stream)
 Creates a new media file to play stream. More...

 
- Static Public Member Functions inherited from Gtk::MediaStream
static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...

 
- Static Public Member Functions inherited from Gdk::Paintable
static void add_interface (GType gtype_implementer)
 
static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...

 

Protected Member Functions

 MediaFile ()
 
virtual void open_vfunc ()
 
virtual void close_vfunc ()
 
- Protected Member Functions inherited from Gtk::MediaStream
virtual bool play_vfunc ()
 
virtual void pause_vfunc ()
 
virtual void seek_vfunc (gint64 timestamp)
 
virtual void update_audio_vfunc (bool muted, double volume)
 
virtual void realize_vfunc (const Glib::RefPtr< Gdk::Surface >& surface)
 
virtual void unrealize_vfunc (const Glib::RefPtr< Gdk::Surface >& surface)
 
- Protected Member Functions inherited from Glib::Object
 Object ()
 
 Object (const Glib::ConstructParams &construct_params)
 
 Object (GObject *castitem)
 
 ~Object () noexcept override
 
- Protected Member Functions inherited from Glib::ObjectBase
 ObjectBase ()
 
 ObjectBase (const char *custom_type_name)
 
 ObjectBase (const std::type_info &custom_type_info)
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 
- Protected Member Functions inherited from Gdk::Paintable
 Paintable ()
 You should derive from this class to use it. More...

 
virtual void snapshot_vfunc (const Glib::RefPtr< Gdk::Snapshot >&snapshot, double width, double height)
 
virtual Glib::RefPtr< Paintableget_current_image_vfunc () const
 
virtual Flags get_flags_vfunc () const
 
virtual int get_intrinsic_width_vfunc () const
 
virtual int get_intrinsic_height_vfunc () const
 
virtual double get_intrinsic_aspect_ratio_vfunc () const
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gtk::MediaFilewrap (GtkMediaFile* object, bool take_copy=false)
 A Glib::wrap() method for this object. More...

 

Additional Inherited Members

- Public Types inherited from Glib::Object
typedef void(*)(gpointer data DestroyNotify)
 
- Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify func_destroy_notify
 
- Public Types inherited from sigc::notifiable
typedef internal::func_destroy_notify func_destroy_notify
 
- Public Types inherited from Gdk::Paintable
enum  Flags {

  Flags::STATIC_SIZE = 1 << 0,

  Flags::STATIC_CONTENTS = 1 << 1

}
 Flags about this object. More...

 

Detailed Description

Open media files for use in GTK.

MediaFile is the implementation for media file usage with MediaStream.

This provides a simple way to play back video files with GTK.

GTK+ provides a GIO extension point for Gtk::MediaFile implementations to allow for external implementations using various media frameworks. GTK+ itself includes implementations using GStreamer and ffmpeg.

See also
Gtk:MediaStream, Gtk::Video
Since gtkmm 3.94:

Constructor & Destructor Documentation

Gtk::MediaFile::MediaFile ( MediaFile&&  src)
noexcept
Gtk::MediaFile::~MediaFile ( )
overridenoexcept
Gtk::MediaFile::MediaFile ( )
protected

Member Function Documentation

void Gtk::MediaFile::clear ( )

Resets the media file to be empty.

virtual void Gtk::MediaFile::close_vfunc ( )
protectedvirtual
static Glib::RefPtr<MediaFile> Gtk::MediaFile::create ( )
static

Creates a new empty media file.

Returns
A new Gtk::MediaFile.
static Glib::RefPtr<MediaFile> Gtk::MediaFile::create ( const Glib::RefPtr< Gio::File > &  file)
static

Creates a new media file to play file.

Parameters
fileThe file to play.
Returns
A new Gtk::MediaFile playing file.
static Glib::RefPtr<MediaFile> Gtk::MediaFile::create ( const Glib::RefPtr< Gio::InputStream > &  stream)
static

Creates a new media file to play stream.

If you want the resulting media to be seekable, the stream should implement the Seekable interface.

Parameters
streamThe stream to play.
Returns
A new Gtk::MediaFile.
static Glib::RefPtr<MediaFile> Gtk::MediaFile::create_for_filename ( const std::string filename)
static

This is a utility function that converts the given filename to a Gio::File and calls new_for_file().

Parameters
filenameFilename to open.
Returns
A new Gtk::MediaFile playing filename.
static Glib::RefPtr<MediaFile> Gtk::MediaFile::create_for_resource ( const std::string resource_path)
static

This is a utility function that converts the given resource to a Gio::File and calls new_for_file().

Parameters
resource_pathResource path to open.
Returns
A new Gtk::MediaFile playing resource_path.
Glib::RefPtr<Gio::File> Gtk::MediaFile::get_file ( )

Returns the file that self is currently playing from.

When self is not playing or not playing from a file, nullptr is returned.

Returns
The currently playing file or nullptr if not playing from a file.
Glib::RefPtr<const Gio::File> Gtk::MediaFile::get_file ( ) const

Returns the file that self is currently playing from.

When self is not playing or not playing from a file, nullptr is returned.

Returns
The currently playing file or nullptr if not playing from a file.
Glib::RefPtr<Gio::InputStream> Gtk::MediaFile::get_input_stream ( )

Returns the stream that self is currently playing from.

When self is not playing or not playing from a stream, nullptr is returned.

Returns
The currently playing stream or nullptr if not playing from a stream.
Glib::RefPtr<const Gio::InputStream> Gtk::MediaFile::get_input_stream ( ) const

Returns the stream that self is currently playing from.

When self is not playing or not playing from a stream, nullptr is returned.

Returns
The currently playing stream or nullptr if not playing from a stream.
static GType Gtk::MediaFile::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

GtkMediaFile* Gtk::MediaFile::gobj ( )
inline

Provides access to the underlying C GObject.

const GtkMediaFile* Gtk::MediaFile::gobj ( ) const
inline

Provides access to the underlying C GObject.

GtkMediaFile* Gtk::MediaFile::gobj_copy ( )

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

virtual void Gtk::MediaFile::open_vfunc ( )
protectedvirtual
MediaFile& Gtk::MediaFile::operator= ( MediaFile&&  src)
noexcept
Glib::PropertyProxy< Glib::RefPtr<Gio::File> > Gtk::MediaFile::property_file ( )

The file being played back or nullptr if not playing a file.

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Gio::File> > Gtk::MediaFile::property_file ( ) const

The file being played back or nullptr if not playing a file.

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.
Glib::PropertyProxy< Glib::RefPtr<Gio::InputStream> > Gtk::MediaFile::property_input_stream ( )

The stream being played back or nullptr if not playing a stream, like when playing a file.

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Gio::InputStream> > Gtk::MediaFile::property_input_stream ( ) const

The stream being played back or nullptr if not playing a stream, like when playing a file.

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.
void Gtk::MediaFile::set_file ( const Glib::RefPtr< Gio::File > &  file)

If any file is still playing, stop playing it.

Then start playing the given file.

Parameters
fileThe file to play.
void Gtk::MediaFile::set_filename ( const std::string filename)

This is a utility function that converts the given filename to a Gio::File and calls set_file().

Parameters
filenameName of file to play.
void Gtk::MediaFile::set_input_stream ( const Glib::RefPtr< Gio::InputStream > &  stream)

If anything is still playing, stop playing it.

Then start playing the given stream.

Full control about the stream is assumed for the duration of playback. The stream will not bt be closed.

Parameters
streamThe stream to play from.
void Gtk::MediaFile::set_resource ( const std::string resource_path)

This is a utility function that converts the given resource_path to a Gio::File and calls set_file().

Parameters
resource_pathPath to resource to play.

Friends And Related Function Documentation

Glib::RefPtr< Gtk::MediaFile > wrap ( GtkMediaFile *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.