Skip to content

Commit

Permalink
Issue #407 - fixed fe.Image.video_playing attribute
Browse files Browse the repository at this point in the history
- wasn't able to reproduce freezing reported in the issue, however
  I was able to fix the other incorrect behaviour reported
  • Loading branch information
mickelson committed Jan 9, 2018
1 parent d2ffea1 commit 02adec7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
22 changes: 15 additions & 7 deletions src/fe_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ bool FeBaseTextureContainer::fix_masked_image()
return false;
}

bool FeBaseTextureContainer::tick( FeSettings *feSettings, bool play_movies, bool ok_to_start )
bool FeBaseTextureContainer::tick( FeSettings *feSettings, bool play_movies )
{
return false;
}
Expand Down Expand Up @@ -650,7 +650,7 @@ void FeTextureContainer::internal_update_selection( FeSettings *feSettings )
notify_texture_change();
}

bool FeTextureContainer::tick( FeSettings *feSettings, bool play_movies, bool ok_to_start )
bool FeTextureContainer::tick( FeSettings *feSettings, bool play_movies )
{
#ifndef NO_SWF
if (( play_movies ) && ( m_swf ))
Expand All @@ -665,8 +665,7 @@ bool FeTextureContainer::tick( FeSettings *feSettings, bool play_movies, bool ok
&& ( m_movie ))
{
if (( m_movie_status > 0 )
&& ( m_movie_status < PLAY_COUNT )
&& ( ok_to_start ))
&& ( m_movie_status < PLAY_COUNT ))
{
//
// We skip the first few "ticks" after the movie
Expand All @@ -677,7 +676,7 @@ bool FeTextureContainer::tick( FeSettings *feSettings, bool play_movies, bool ok
m_movie_status++;
return false;
}
else if (( m_movie_status == PLAY_COUNT ) && ( ok_to_start ))
else if ( m_movie_status == PLAY_COUNT )
{
m_movie_status++;

Expand All @@ -704,12 +703,21 @@ void FeTextureContainer::set_play_state( bool play )
#ifndef NO_MOVIE
if (m_movie)
{
if ( m_movie_status >= PLAY_COUNT )
if ( play == get_play_state() )
return;

if ( m_movie_status > PLAY_COUNT )
{
if ( play )
{
m_movie->setLoop( !(m_video_flags & VF_NoLoop) );
m_movie->play();
}
else
{
m_movie->setLoop( false );
m_movie->stop();
}
}
else if ( m_movie_status >= 0 )
{
Expand All @@ -735,7 +743,7 @@ bool FeTextureContainer::get_play_state() const
#ifndef NO_MOVIE
if ( m_movie )
{
if ( m_movie_status >= PLAY_COUNT )
if ( m_movie_status > PLAY_COUNT )
return m_movie->is_playing();
else
// if status > 0, we are in the process of starting to play
Expand Down
4 changes: 2 additions & 2 deletions src/fe_image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class FeBaseTextureContainer

virtual void on_new_list( FeSettings *, bool new_display )=0;

virtual bool tick( FeSettings *feSettings, bool play_movies, bool ok_to_start ); // returns true if redraw required
virtual bool tick( FeSettings *feSettings, bool play_movies ); // returns true if redraw required

virtual void set_play_state( bool play );
virtual bool get_play_state() const;
Expand Down Expand Up @@ -124,7 +124,7 @@ class FeTextureContainer : public FeBaseTextureContainer
void on_end_navigation( FeSettings *feSettings );
void on_new_list( FeSettings *, bool );

bool tick( FeSettings *feSettings, bool play_movies, bool ok_to_start ); // returns true if redraw required
bool tick( FeSettings *feSettings, bool play_movies ); // returns true if redraw required
void set_play_state( bool play );
bool get_play_state() const;
void set_vol( float vol );
Expand Down
2 changes: 1 addition & 1 deletion src/fe_present.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ bool FePresent::video_tick()
for ( std::vector<FeBaseTextureContainer *>::iterator itm=m_texturePool.begin();
itm != m_texturePool.end(); ++itm )
{
if ( (*itm)->tick( m_feSettings, m_playMovies, true ) )
if ( (*itm)->tick( m_feSettings, m_playMovies ) )
ret_val=true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/media.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ void FeMedia::close()
bool FeMedia::is_playing()
{
if ((m_video) && (!m_video->at_end))
return true;
return (m_video->run_video_thread);

return ((m_audio) && (sf::SoundStream::getStatus() == sf::SoundStream::Playing));
}
Expand Down

1 comment on commit 02adec7

@oomek
Copy link
Collaborator

@oomek oomek commented on 02adec7 Jan 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Freezes are gone after setting video_playing = true twice in a row, but now setting video_playing = false is restarting the video.

Please sign in to comment.