Opening Video
I have searched through the API library and looked through the default game manager script but can not find an example of how to add video in .ogg format as shown in the blog for opening screens.
can you help?
obj = 0;
videos = {};
VIDEO_IDENT = "ident";
VIDEO_02 = "video02";
function onInit(objID)
obj = objID;
--sky.print("Scene Script Acitve");
end
function onStop()
destroyAllVideos();
-- Set the material back to No texture
material.setUnlitTexture( "LightSource", "null"); -- use null to remove the texture
end
function onUpdate( td )
updateVideos();
end
function onKeyDown( key )
if(key == "1")then
-- | Create the fullscreen cutscene video
createVideo( "_Skyline_Ident.ogg", VIDEO_IDENT, true );
-- | Create the second video and render it on an object
createVideo( "bunny.ogg", VIDEO_02, false );
setVideoOnMaterial( "LightSource", VIDEO_02 );
playVideo(VIDEO_02);
end
if(key == "2")then
destroyVideo( VIDEO_IDENT );
end
if(key == "3")then
pauseVideo( VIDEO_IDENT );
end
if(key == "4")then
playVideo( VIDEO_IDENT );
end
-- Show/ Hide the fullscreen overlay for cutscenes
if(key == "9")then
video.ShowFullscreenPlayer( videos[VIDEO_IDENT] );
end
if(key == "0")then
video.HideFullscreenPlayer();
end
end
-- | ===============================================================================================================
-- | Video Utility functions that will allow you to load and render videos quickly and keep management of the videos.
-- | ===============================================================================================================
function keyExists(table, element)
for key, value in pairs(table) do
if key == element then
return true
end
end
return false
end
--/;/ EnumVidErrors
ENUM_exists = 0; ENUM_exists_empty =1; ENUM_Unused =2;
function isVideoValid( alias )
if( keyExists(videos, alias) == true)then
if(videos[alias] > -1)then
return ENUM_exists;
else
return ENUM_exists_empty;
end
end
return ENUM_Unused;
end
function createVideo( clip, alias, autoplay )
if(isVideoValid(alias) == ENUM_exists)then return videos[alias]; end
videos[alias] = video.create(clip);
if(videos[alias] == -1)then
lprint("Error: Failed to create video of name: "..clip.." and alias: "..alias);
return -1;
end
if(autoplay == true)then
video.ShowFullscreenPlayer(videos[alias]);
else
video.pause(videos[alias]);
end
-- return the id if needed
return videos[alias];
end
function destroyVideo( alias )
if(isVideoValid(alias) ~= ENUM_exists)then return; end
video.stop(videos[alias]);
video.HideFullscreenPlayer();
video.destroy(videos[alias]);
videos[alias] = nil;
end
function destroyAllVideos()
for key, value in pairs(videos) do
destroyVideo( key );
end
end
function pauseVideo( alias )
if(isVideoValid(alias) ~= ENUM_exists)then return; end
video.pause(videos[alias]);
end
function playVideo( alias )
if(isVideoValid(alias) ~= ENUM_exists)then return; end
video.play(videos[alias]);
end
function updateVideos()
for key, value in pairs(videos) do
isVideoFinished( key );
end
end
function setVideoOnMaterial( matname, alias)
if(isVideoValid(alias) ~= ENUM_exists)then return; end
vidTex = video.getTextureName(videos[alias]);
if(vidTex == "")then return; end
material.setUnlitTexture(matname, vidTex, 1); -- The 1 signifies to place a RTT on the material
end
function isVideoFinished( alias )
if( isVideoValid(alias) ~= ENUM_exists )then return; end
if( video.isDone(videos[alias]) == 1 )then
video.HideFullscreenPlayer(videos[alias]);
video.destroy(videos[alias]);
videos[alias] = -1;
end
end
Users browsing this forum: No registered users and 1 guest