Top |
int | back | Read / Write |
char * | current-uri | Read |
int | forward | Read / Write |
gboolean | mute | Read / Write / Construct |
int | pause | Read / Write |
gboolean | repeat-all | Read / Write |
gboolean | repeat-selection | Read / Write |
double | speed | Read / Write / Construct |
int | state | Read |
char * | timestamp-delimiter | Read / Write / Construct |
gboolean | timestamp-fixed | Read / Write / Construct |
char * | timestamp-fraction-sep | Read / Write / Construct |
int | timestamp-precision | Read / Write / Construct |
double | volume | Read / Write / Construct |
void | asr-final | Run First |
void | asr-hypothesis | Run First |
void | end-of-stream | Run First |
void | error | Run First |
void | jumped-back | Run First |
void | jumped-forward | Run First |
void | play-toggled | Run First |
PtPlayer is the GStreamer backend for Parlatype. Construct it with pt_player_new()
.
Then you have to open a file with pt_player_open_uri()
.
The internal time unit in PtPlayer are milliseconds.
PtPlayer *
pt_player_new (void
);
Returns a new PtPlayer in PT_MODE_PLAYBACK. The next step would be to open
a file with pt_player_open_uri()
.
After use g_object_unref()
it.
Since: 1.6
void pt_player_set_mode (PtPlayer *player
,PtModeType type
);
Set output mode. Initially PtPlayer is in PT_MODE_PLAYBACK. Before switching
to PT_MODE_ASR the programmer has to call pt_player_configure_asr()
and check
the result. Setting the mode is an asynchronous operation and when done in
paused state, it will happen only during the change to playing state.
To get the results in ASR mode, connect to the “asr-hypothesis” and/or
“asr-final” signal. Start recognition with pt_player_play()
.
Since: 3.0
PtModeType
pt_player_get_mode (PtPlayer *player
);
Get current output mode.
Since: 3.0
gboolean pt_player_configure_asr (PtPlayer *player
,PtConfig *config
,GError **error
);
Configure ASR setup with a PtConfig instance. This is necessary before switching into PT_MODE_ASR the first time. The configuration remains if you switch to normal playback and back to ASR again. Subsequently it can be changed in both modes.
Since: 3.0
gboolean pt_player_config_is_loadable (PtPlayer *player
,PtConfig *config
);
Checks if PtPlayer is able to load the GStreamer plugin used by config
without actually loading it. It does not guarantee that the plugin is
functional, merely that it is either a private plugin of PtPlayer itself
or an installed external plugin.
Since: 3.0
gboolean pt_player_open_uri (PtPlayer *player
,gchar *uri
);
Opens a local audio file for playback. It doesn’t work with videos or streams. Only one file can be open at a time, playlists are not supported by the backend. Opening a new file will close the previous one.
When closing a file or on object destruction PtPlayer tries to write the last position into the file’s metadata. On opening a file it reads the metadata and jumps to the last known position if found.
The player is set to the paused state and ready for playback. To start
playback use
.pt_player_play()
This operation blocks until it is finished. It returns TRUE on success or FALSE on error. Errors are emitted async via “error” signal.
Since: 2.0
void
pt_player_play (PtPlayer *player
);
Starts playback in playback mode at the defined speed until it reaches the end of stream (or the end of the selection). If the current position is at the end, playback will start from the beginning of the stream or selection.
In ASR mode it starts decoding the stream silently at the fastest possible speed and emitting textual results via the “asr-hypothesis” and “asr-final” signals.
Since: 1.4
void
pt_player_play_pause (PtPlayer *player
);
Toggles between playback and pause, rewinds on pause.
Since: 1.6
void
pt_player_pause (PtPlayer *player
);
Sets the player to the paused state, meaning it stops playback and doesn’t
change position. To resume playback use
.pt_player_play()
Since: 1.4
void
pt_player_pause_and_rewind (PtPlayer *player
);
Like
, additionally rewinds the value of
“pause” in milliseconds.pt_player_pause()
Since: 1.6
gint
pt_player_get_pause (PtPlayer *player
);
Returns the value of “pause”.
Since: 1.6
void pt_player_connect_waveviewer (PtPlayer *player
,PtWaveviewer *wv
);
Connect a PtWaveviewer. The PtPlayer will monitor selections made in the PtWaveviewer and act accordingly.
Since: 1.6
void pt_player_set_selection (PtPlayer *player
,gint64 start
,gint64 end
);
Set a selection. If the current position is outside the selection, it will be set to the selection’s start position, otherwise the current position is not changed. Playing will end at the stop position and it’s not possible to jump out of the selection until it is cleared with pt_player_clear_selection.
player |
a PtPlayer |
|
start |
selection start time in milliseconds |
|
end |
selection end time in milliseconds |
Since: 1.5
void
pt_player_clear_selection (PtPlayer *player
);
Clear and reset any selection.
Since: 1.5
gboolean
pt_player_selection_active (PtPlayer *player
);
Returns whether there is currently a selection set or not.
Since: 1.6
void pt_player_jump_relative (PtPlayer *player
,gint milliseconds
);
Skips milliseconds
in stream. A positive value means jumping ahead. If the
resulting position would be beyond the end of stream (or selection), it goes
to the end of stream (or selection). A negative value means jumping back.
If the resulting position would be negative (or before the selection), it
jumps to position 0:00 (or to the start of the selection).
Since: 1.4
void
pt_player_jump_back (PtPlayer *player
);
Jumps back the value of “back”.
Since: 1.6
void
pt_player_jump_forward (PtPlayer *player
);
Jumps forward the value of “forward”.
Since: 1.6
gint
pt_player_get_back (PtPlayer *player
);
Returns the value of “back”.
Since: 1.6
gint
pt_player_get_forward (PtPlayer *player
);
Returns the value of “forward”.
Since: 1.6
void pt_player_jump_to_position (PtPlayer *player
,gint milliseconds
);
Jumps to a given position in stream. The position is given in milliseconds
starting from position 0:00. A position beyond the duration of stream (or
outside the selection) is ignored.
Since: 1.4
gdouble
pt_player_get_speed (PtPlayer *player
);
Returns current playback speed.
Since: 3.1
void pt_player_set_speed (PtPlayer *player
,gdouble speed
);
Sets the speed of playback in the paused state as well as during playback.
Normal speed is 1.0, everything above that is faster, everything below slower.
A speed of 0 is not allowed, use pt_player_pause()
instead.
Recommended speed is starting from 0.5 as quality is rather poor below that.
Parlatype doesn’t change the pitch during slower or faster playback.
Since: 1.4
gdouble
pt_player_get_volume (PtPlayer *player
);
Gets the volume on a scale between 0 and 1.
Since: 2.1
void pt_player_set_volume (PtPlayer *player
,gdouble volume
);
Sets the volume on a scale between 0 and 1. Instead of using this method you could set the "volume" property.
Since: 1.4
gboolean
pt_player_get_mute (PtPlayer *player
);
Get mute state of the audio stream.
Since: 2.1
void pt_player_set_mute (PtPlayer *player
,gboolean mute
);
Mute the player (with TRUE) or set it back to normal volume (with FALSE). This remembers the volume level, so you don’t have to keep track of the old value.
Since: 2.1
gint64
pt_player_get_position (PtPlayer *player
);
Returns the current position in stream.
Since: 1.5
gint64
pt_player_get_duration (PtPlayer *player
);
Returns the duration of stream.
Since: 1.5
gchar *
pt_player_get_uri (PtPlayer *player
);
Returns the URI of the currently open file or NULL if it can’t be determined.
Since: 1.4
gchar *
pt_player_get_filename (PtPlayer *player
);
Returns the display name of the currently open file or NULL if it can’t be determined.
Since: 1.4
gchar * pt_player_get_time_string (gint time
,gint duration
,PtPrecisionType precision
);
Returns the given time as a string for display to the user. Format type is
determined by duration
, e.g. if duration is long format, it returns a string
in long format, too.
time |
time in milliseconds to converse |
|
duration |
duration of stream in milliseconds (max time) |
|
precision |
Since: 1.4
gchar * pt_player_get_current_time_string (PtPlayer *player
,PtPrecisionType precision
);
Returns the current position of the stream as a string for display to the user.
If the current position can not be determined, NULL is returned.
Since: 1.4
gchar * pt_player_get_duration_time_string (PtPlayer *player
,PtPrecisionType precision
);
Returns the duration of the stream as a string for display to the user.
If the duration can not be determined, NULL is returned.
Since: 1.4
gchar * pt_player_get_timestamp_for_time (PtPlayer *player
,gint time
,gint duration
);
Returns the timestamp for the given time as a string. Duration is needed for some short time formats, the resulting timestamp format depends on whether duration is less than one hour or more than (including) an hour (3600000 milliseconds).
The format of the timestamp can be influenced with “timestamp-precision”, “timestamp-fixed”, “timestamp-fraction-sep” and “timestamp-delimiter”.
Since: 1.6
gchar *
pt_player_get_timestamp (PtPlayer *player
);
Returns the current timestamp as a string. The format of the timestamp can be influenced with “timestamp-precision”, “timestamp-fixed”, “timestamp-fraction-sep” and “timestamp-delimiter”.
If the current position can not be determined, NULL is returned.
Since: 1.4
gint pt_player_get_timestamp_position (PtPlayer *player
,gchar *timestamp
,gboolean check_duration
);
Returns the time in milliseconds represented by the timestamp or -1 for invalid timestamps.
player |
a PtPlayer |
|
timestamp |
the timestamp |
|
check_duration |
checking the timestamp’s validity also check duration |
Since: 1.6
gboolean pt_player_string_is_timestamp (PtPlayer *player
,gchar *timestamp
,gboolean check_duration
);
Returns whether the given string is a valid timestamp. With check_duration
FALSE it checks only for the formal validity of the timestamp. With
check_duration
TRUE the timestamp must be within the duration to be valid.
See also pt_player_goto_timestamp()
if you want to go to the timestamp’s
position immediately after.
player |
a PtPlayer |
|
timestamp |
the string to be checked |
|
check_duration |
whether timestamp’s time is less or equal stream’s duration |
Since: 1.4
struct PtPlayer;
The PtPlayer contains only private fields and should not be directly accessed.
“back”
property “back” int
Milliseconds to jump back.
Owner: PtPlayer
Flags: Read / Write
Allowed values: [1000,60000]
Default value: 10000
“current-uri”
property “current-uri” char *
URI of the currently loaded stream.
Owner: PtPlayer
Flags: Read
Default value: NULL
“forward”
property “forward” int
Milliseconds to jump forward.
Owner: PtPlayer
Flags: Read / Write
Allowed values: [1000,60000]
Default value: 10000
“mute”
property“mute” gboolean
Mute state of the audio stream.
Owner: PtPlayer
Flags: Read / Write / Construct
Default value: FALSE
“pause”
property “pause” int
Milliseconds to rewind on pause.
Owner: PtPlayer
Flags: Read / Write
Allowed values: [0,10000]
Default value: 0
“repeat-all”
property“repeat-all” gboolean
"Play" at the end of the file replays it.
Owner: PtPlayer
Flags: Read / Write
Default value: FALSE
“repeat-selection”
property“repeat-selection” gboolean
"Play" at the end of a selection replays it.
Owner: PtPlayer
Flags: Read / Write
Default value: FALSE
“speed”
property “speed” double
The speed for playback.
Owner: PtPlayer
Flags: Read / Write / Construct
Allowed values: [0.1,2]
Default value: 1
“state”
property “state” int
The current state of PtPlayer.
Owner: PtPlayer
Flags: Read
Allowed values: [0,4]
Default value: 0
“timestamp-delimiter”
property “timestamp-delimiter” char *
Character to delimit start and end of timestamp. Allowed values are "None", hashtag "#", left bracket "(" and left square bracket "[". PtPlayer will of course end with a right (square) bracket if those are chosen. Any other character is changed to a hashtag "#".
Owner: PtPlayer
Flags: Read / Write / Construct
Default value: "#"
“timestamp-fixed”
property“timestamp-fixed” gboolean
Whether timestamp format should have a fixed number of digits.
Owner: PtPlayer
Flags: Read / Write / Construct
Default value: FALSE
“timestamp-fraction-sep”
property “timestamp-fraction-sep” char *
Character to separate fractions of a second from seconds. Only point "." and minus "-" are allowed. Any other character is changed to a point ".".
Owner: PtPlayer
Flags: Read / Write / Construct
Default value: "."
“timestamp-precision”
property “timestamp-precision” int
How precise timestamps should be.
Owner: PtPlayer
Flags: Read / Write / Construct
Allowed values: [0,3]
Default value: 1
“volume”
property “volume” double
The volume for playback.
Pulseaudio sink does not propagate volume changes at GST_STATE_PAUSED or lower. This property will notify of changes only in GST_STATE_PLAYING and on state changes, e.g. from GST_STATE_READY to GST_STATE_PAUSED. Getting this property returns the real current volume level even if there was no notification before.
Owner: PtPlayer
Flags: Read / Write / Construct
Allowed values: [0,1]
Default value: 1
“asr-final”
signalvoid user_function (PtPlayer *player, char *word, gpointer user_data)
The “asr-final” signal is emitted in automatic speech recognition mode whenever a word or a sequence of words was recognized and won’t change anymore. For intermediate results see “asr-hypothesis”.
player |
the player emitting the signal |
|
word |
recognized word(s) |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“asr-hypothesis”
signalvoid user_function (PtPlayer *player, char *word, gpointer user_data)
The “asr-hypothesis” signal is emitted in automatic speech recognition mode as an intermediate result (hypothesis) of recognized words. The hypothesis can still change. The programmer is responsible for replacing an emitted hypothesis by either the next following hypothesis or a following “asr-final” signal.
It’s not necessary to connect to this signal if you want the final result only. However, it can take a few seconds until a final result is emitted and without an intermediate hypothesis the end user might have the impression that there is nothing going on.
player |
the player emitting the signal |
|
word |
probably recognized word(s) |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“end-of-stream”
signalvoid user_function (PtPlayer *player, gpointer user_data)
The “end-of-stream” signal is emitted when the stream is at its end or when the end of selection is reached.
player |
the player emitting the signal |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“error”
signalvoid user_function (PtPlayer *player, GError *error, gpointer user_data)
The “error” signal is emitted on errors opening the file or during playback. It’s a severe error and the player is always reset.
player |
the player emitting the signal |
|
error |
a GError |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“jumped-back”
signalvoid user_function (PtPlayer *player, gpointer user_data)
The “jumped-back” signal is emitted when the player jumped back.
player |
the player emitting the signal |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“jumped-forward”
signalvoid user_function (PtPlayer *player, gpointer user_data)
The “jumped-forward” signal is emitted when the player jumped forward.
player |
the player emitting the signal |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“play-toggled”
signalvoid user_function (PtPlayer *player, gpointer user_data)
The “play-toggled” signal is emitted when the player changed to pause or play.
player |
the player emitting the signal |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First