How do I play a video in part of the screen in iOS
This lesson shows you how to create an iOS video controller and load a video.
Setup your stack and simulation settings
-) Create a new stack
-) Resize it to 1024 x 768
-) File > Standalone application settings
1) Go to the iOS tab
2) For the purposes of this example set "Supported Devices" to 'iPad'. This tutorial applies equally to iPhone and iPods
Setup your video file
For this test we need a video. We've exported a portion of the 4.6 promo video at a low quality which is contained in the sample zip attached to this lesson. We need to include it in our build:
1) In the standalone setting pane, go to 'Copy Files'
2) Click 'Add File..." to browse to our video file
3) It should appear in the list
We should now have a stack that is setup for simulation with our video file included. We can start coding.
Create our control in script
Open the card script and paste the following code. The green comments explain what we are doing.
// Check the control doesn't already exist. If so delete and recreate it
if "ioscontrol" is among the lines of iphoneControls() then
iphoneControlCreate "player", "ioscontrol"
// Set the basic properties including visibility, rectangle and video file path
iphoneControlSet "ioscontrol", "filename", specialFolderPath("engine") & "/video.mp4"
iphoneControlSet "ioscontrol", "preserveAspect", true
iphoneControlSet "ioscontrol", "showController", true
iphoneControlSet "ioscontrol", "visible", true
iphoneControlSet "ioscontrol", "rect", "250,200,783,500"
// Start playing the video
iphoneControlDo "ioscontrol", "play"
// Delete the control when we leave the card
// Delete the control