Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximper-welcome
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
ximper-welcome
Commits
1c24350a
Commit
1c24350a
authored
Aug 18, 2020
by
Bilal Elmoussaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correctly play the video, avoid looping
parent
db973214
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
13 deletions
+21
-13
welcome.rs
src/widgets/pages/welcome.rs
+21
-13
No files found.
src/widgets/pages/welcome.rs
View file @
1c24350a
...
...
@@ -15,6 +15,7 @@ use std::cell::RefCell;
#[cfg(feature
=
"video"
)]
pub
enum
Action
{
VideoReady
,
VideoUp
,
}
pub
struct
WelcomePageWidget
{
...
...
@@ -105,27 +106,34 @@ impl WelcomePageWidget {
#[cfg(feature
=
"video"
)]
{
let
receiver
=
self
.receiver
.borrow_mut
()
.take
()
.unwrap
();
receiver
.attach
(
None
,
move
|
action
|
{
if
action
==
Action
::
VideoReady
{
header
.get_style_context
()
.add_class
(
"playing"
);
}
glib
::
Continue
(
true
)
});
let
video_file
=
gio
::
File
::
new_for_path
(
config
::
VIDEO_PATH
);
self
.player
.set_uri
(
&
video_file
.get_uri
());
receiver
.attach
(
None
,
clone!
(
@
strong
self
.player
as
player
=>
move
|
action
|
{
match
action
{
Action
::
VideoReady
=>
player
.play
(),
Action
::
VideoUp
=>
header
.get_style_context
()
.add_class
(
"playing"
),
};
glib
::
Continue
(
true
)
}),
);
self
.player
.connect_state_changed
(
clone!
(
@
strong
self
.sender
as
sender
=>
move
|
_
,
state
|
{
self
.player
.connect_state_changed
(
clone!
(
@
strong
self
.sender
as
sender
=>
move
|
_
p
,
state
|
{
if
state
==
gst_player
::
PlayerState
::
Playing
{
sender
.send
(
Action
::
Video
Ready
)
.unwrap
();
sender
.send
(
Action
::
Video
Up
)
.unwrap
();
}
}));
self
.player
.connect_uri_loaded
(
clone!
(
@
strong
self
.sender
as
sender
=>
move
|
_p
,
_uri
|
{
sender
.send
(
Action
::
VideoReady
)
.unwrap
();
}));
self
.player
.connect_end_of_stream
(
move
|
p
|
p
.stop
());
let
video_file
=
gio
::
File
::
new_for_path
(
config
::
VIDEO_PATH
);
gtk
::
timeout_add
(
500
,
clone!
(
@
strong
self
.player
as
player
=>
move
||
{
player
.
play
(
);
glib
::
Continue
(
tru
e
)
player
.
set_uri
(
&
video_file
.get_uri
()
);
glib
::
Continue
(
fals
e
)
}),
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment