test_movie_texture.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. from panda3d.core import MovieVideo
  2. from panda3d.core import MovieTexture
  3. from panda3d.core import Filename
  4. from panda3d.core import PandaSystem
  5. from panda3d.core import MovieTexture
  6. import pytest
  7. import os
  8. def check_ffmpeg():
  9. # Make sure video plug-ins are loaded
  10. MovieVideo.get("test.mp4")
  11. system = PandaSystem.get_global_ptr()
  12. return 'FFmpeg' in system.systems #checks whether ffmpeg is loaded
  13. @pytest.mark.skipif(not check_ffmpeg(), reason="skip when ffmpeg is not available")
  14. class Test_Texture_Movie():
  15. def test_texture_loop_count(self):
  16. movie_path = os.path.join(os.path.dirname(__file__), "small.mp4")
  17. movie_path = Filename.from_os_specific(movie_path) # enables Platform independent testing
  18. reference_file = MovieVideo.get(movie_path)
  19. reference_texture = MovieTexture(reference_file)
  20. assert reference_texture.get_loop_count() == 1
  21. def test_video_is_playing(self): #This test checks isPlaying() and stop() functionality
  22. movie_path = os.path.join(os.path.dirname(__file__), "small.mp4")
  23. movie_path = Filename.from_os_specific(movie_path) # enables Platform independent testing
  24. reference_file = MovieVideo.get(movie_path)
  25. reference_texture = MovieTexture(reference_file)
  26. reference_texture.play()
  27. assert reference_texture.is_playing() is True
  28. reference_texture.stop()
  29. assert reference_texture.is_playing() is False
  30. def test_play_rate(self):
  31. movie_path = os.path.join(os.path.dirname(__file__), "small.mp4")
  32. movie_path = Filename.from_os_specific(movie_path) # enables Platform independent testing
  33. reference_file = MovieVideo.get(movie_path)
  34. reference_texture = MovieTexture(reference_file)
  35. assert reference_texture.get_play_rate() == 1
  36. reference_texture.set_play_rate(2)
  37. assert reference_texture.get_play_rate() == 2
  38. def test_video_texture_length(self):
  39. movie_path = os.path.join(os.path.dirname(__file__), "small.mp4")
  40. movie_path = Filename.from_os_specific(movie_path) # enables Platform independent testing
  41. reference_file = MovieVideo.get(movie_path)
  42. reference_texture = MovieTexture(reference_file)
  43. assert reference_texture.get_video_length() == 32.480 #got info from mkvinfo