diff options
Diffstat (limited to 'scene/gui/video_player.cpp')
-rw-r--r-- | scene/gui/video_player.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 9b9c797ed9..517cd414c5 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "video_player.h" - +#include "os/os.h" int VideoPlayer::InternalStream::get_channel_count() const { @@ -117,8 +117,9 @@ void VideoPlayer::_notification(int p_notification) { case NOTIFICATION_ENTER_TREE: { //set_idle_process(false); //don't annoy - if (stream.is_valid() && autoplay && !get_tree()->is_editor_hint()) + if (stream.is_valid() && autoplay && !get_tree()->is_editor_hint()) { play(); + } } break; case NOTIFICATION_PROCESS: { @@ -130,7 +131,7 @@ void VideoPlayer::_notification(int p_notification) { if (!playback->is_playing()) return; - double audio_time = AudioServer::get_singleton()->get_mix_time(); + double audio_time = OS::get_singleton()->get_ticks_usec()/1000000.0; //AudioServer::get_singleton()->get_mix_time(); double delta = last_audio_time==0?0:audio_time-last_audio_time; last_audio_time=audio_time; @@ -270,6 +271,7 @@ void VideoPlayer::set_paused(bool p_paused) { playback->set_paused(p_paused); set_process(!p_paused); }; + last_audio_time = 0; }; bool VideoPlayer::is_paused() const { @@ -338,6 +340,13 @@ float VideoPlayer::get_stream_pos() const { return playback->get_pos(); }; +Ref<Texture> VideoPlayer::get_video_texture() { + + if (playback.is_valid()) + return playback->get_texture(); + + return Ref<Texture> (); +} void VideoPlayer::set_autoplay(bool p_enable) { @@ -384,6 +393,8 @@ void VideoPlayer::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_buffering_msec","msec"),&VideoPlayer::set_buffering_msec); ObjectTypeDB::bind_method(_MD("get_buffering_msec"),&VideoPlayer::get_buffering_msec); + ObjectTypeDB::bind_method(_MD("get_video_texutre:Texture"), &VideoPlayer::get_video_texture ); + ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/audio_track",PROPERTY_HINT_RANGE,"0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track") ); ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"VideoStream"), _SCS("set_stream"), _SCS("get_stream") ); // ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") ); |