/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #include #include #include #include #include #include "VideoPlaybackFrameworkSystemComponent.h" #include "Include/VideoPlaybackFramework/VideoPlaybackAsset.h" #include "Include/VideoPlaybackFramework/VideoPlaybackBus.h" namespace VideoPlaybackFramework { class BehaviorVideoPlaybackNotificationBusHandler : public VideoPlaybackNotificationBus::Handler , public AZ::BehaviorEBusHandler { public: AZ_EBUS_BEHAVIOR_BINDER(BehaviorVideoPlaybackNotificationBusHandler, "{F3116FA1-3F81-4ADE-9941-C5A5C838197B}", AZ::SystemAllocator, OnPlaybackStarted, OnPlaybackPaused, OnPlaybackStopped, OnPlaybackFinished, OnFirstFramePresented ); // Sent when playback starts or resumes void OnPlaybackStarted() override { Call(FN_OnPlaybackStarted); } // Sent when the video is paused void OnPlaybackPaused() override { Call(FN_OnPlaybackPaused); } // Sent when the video is stopped void OnPlaybackStopped() override { Call(FN_OnPlaybackStopped); } // Sent when the video finishes void OnPlaybackFinished() override { Call(FN_OnPlaybackFinished); } // Sent when the video decodes first frame void OnFirstFramePresented() override { Call(FN_OnFirstFramePresented); } }; void VideoPlaybackFrameworkSystemComponent::Reflect(AZ::ReflectContext* context) { if (AZ::SerializeContext* serialize = azrtti_cast(context)) { AzFramework::SimpleAssetReference::Register(*serialize); serialize->Class() ->Version(0) ; if (AZ::EditContext* ec = serialize->GetEditContext()) { ec->Class("VideoPlaybackFramework", "Interface framework to play back video during gameplay.") ->ClassElement(AZ::Edit::ClassElements::EditorData, "") ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System")) ->Attribute(AZ::Edit::Attributes::AutoExpand, true) ; } } if (AZ::BehaviorContext* behaviorContext = azrtti_cast(context)) { behaviorContext->EBus("VideoPlaybackRequestBus") ->Event("Play", &VideoPlaybackRequestBus::Events::Play) ->Event("Pause", &VideoPlaybackRequestBus::Events::Pause) ->Event("Stop", &VideoPlaybackRequestBus::Events::Stop) ->Event("IsPlaying", &VideoPlaybackRequestBus::Events::IsPlaying) ->Event("GetQueueAheadCount", &VideoPlaybackRequestBus::Events::GetQueueAheadCount) ->Event("SetQueueAheadCount", &VideoPlaybackRequestBus::Events::SetQueueAheadCount) ->Event("GetIsLooping", &VideoPlaybackRequestBus::Events::GetIsLooping) ->Event("SetIsLooping", &VideoPlaybackRequestBus::Events::SetIsLooping) ->Event("GetIsAutoPlay", &VideoPlaybackRequestBus::Events::GetIsAutoPlay) ->Event("SetIsAutoPlay", &VideoPlaybackRequestBus::Events::SetIsAutoPlay) ->Event("GetPlaybackSpeed", &VideoPlaybackRequestBus::Events::GetPlaybackSpeed) ->Event("SetPlaybackSpeed", &VideoPlaybackRequestBus::Events::SetPlaybackSpeed) ->Event("GetVideoPathname", &VideoPlaybackRequestBus::Events::GetVideoPathname) ->Event("SetVideoPathname", &VideoPlaybackRequestBus::Events::SetVideoPathname) ->Event("GetDestinationTextureName", &VideoPlaybackRequestBus::Events::GetDestinationTextureName) ->Event("SetDestinationTextureName", &VideoPlaybackRequestBus::Events::SetDestinationTextureName) ; behaviorContext->EBus("VideoPlaybackNotificationBus") ->Handler() ; } } void VideoPlaybackFrameworkSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided) { provided.push_back(AZ_CRC("VideoPlaybackFrameworkService")); } void VideoPlaybackFrameworkSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible) { incompatible.push_back(AZ_CRC("VideoPlaybackFrameworkService")); } void VideoPlaybackFrameworkSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required) { (void)required; } void VideoPlaybackFrameworkSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent) { (void)dependent; } void VideoPlaybackFrameworkSystemComponent::Init() { } void VideoPlaybackFrameworkSystemComponent::Activate() { VideoPlaybackFrameworkRequestBus::Handler::BusConnect(); EBUS_EVENT(AZ::Data::AssetCatalogRequestBus, EnableCatalogForAsset, azrtti_typeid()); EBUS_EVENT(AZ::Data::AssetCatalogRequestBus, AddExtension, "mp4"); EBUS_EVENT(AZ::Data::AssetCatalogRequestBus, AddExtension, "mkv"); EBUS_EVENT(AZ::Data::AssetCatalogRequestBus, AddExtension, "webm"); EBUS_EVENT(AZ::Data::AssetCatalogRequestBus, AddExtension, "mov"); } void VideoPlaybackFrameworkSystemComponent::Deactivate() { VideoPlaybackFrameworkRequestBus::Handler::BusDisconnect(); } }