123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- #ifndef __COCOS2D_UI_VIDEOWEIGTH_H_
- #define __COCOS2D_UI_VIDEOWEIGTH_H_
- #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) && !defined(CC_PLATFORM_OS_TVOS)
- #include "ui/UIWidget.h"
- NS_CC_BEGIN
- namespace experimental{
- namespace ui{
-
- class VideoPlayer : public cocos2d::ui::Widget
- {
- public:
-
- enum class EventType
- {
- PLAYING = 0,
- PAUSED,
- STOPPED,
- COMPLETED
- };
-
- typedef std::function<void(Ref*,VideoPlayer::EventType)> ccVideoPlayerCallback;
-
- CREATE_FUNC(VideoPlayer);
-
- virtual void setFileName(const std::string& videoPath);
-
-
- virtual const std::string& getFileName() const { return _videoURL;}
-
- virtual void setURL(const std::string& _videoURL);
-
-
- virtual const std::string& getURL() const { return _videoURL;}
-
- virtual void play();
-
- virtual void pause()override;
-
- virtual void resume()override;
-
- virtual void stop();
-
- virtual void seekTo(float sec);
-
- virtual bool isPlaying() const;
-
- virtual void setKeepAspectRatioEnabled(bool enable);
-
- virtual bool isKeepAspectRatioEnabled()const { return _keepAspectRatioEnabled;}
-
- virtual void setFullScreenEnabled(bool fullscreen);
-
- virtual bool isFullScreenEnabled()const;
-
- virtual void addEventListener(const VideoPlayer::ccVideoPlayerCallback& callback);
-
-
- virtual void onPlayEvent(int event);
- virtual void setVisible(bool visible) override;
- virtual void draw(Renderer *renderer, const Mat4& transform, uint32_t flags) override;
- virtual void onEnter() override;
- virtual void onExit() override;
- protected:
- virtual cocos2d::ui::Widget* createCloneInstance() override;
- virtual void copySpecialProperties(Widget* model) override;
-
- CC_CONSTRUCTOR_ACCESS:
- VideoPlayer();
- virtual ~VideoPlayer();
- protected:
- #if CC_VIDEOPLAYER_DEBUG_DRAW
- DrawNode *_debugDrawNode;
- #endif
- enum class Source
- {
- FILENAME = 0,
- URL
- };
- bool _isPlaying;
- bool _fullScreenDirty;
- bool _fullScreenEnabled;
- bool _keepAspectRatioEnabled;
- std::string _videoURL;
- Source _videoSource;
- int _videoPlayerIndex;
- ccVideoPlayerCallback _eventCallback;
- void* _videoView;
- };
- }
- }
- NS_CC_END
- #endif
- #endif
|