revUp - Updates and news for the LiveCode community
Issue 107 | March 24th 2011 Contact the Editor | How to Contribute

Play Part Screen Video
LiveCode 4.6 now lets you play back videos in part of the screen on iOS. Here's how you do it.

By Ben Beaumont

This lesson shows you how to create an iOS video controller and load a video.

Attached Files

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.

on openCard
// Check the control doesn't already exist. If so delete and recreate it
if "ioscontrol" is among the lines of iphoneControls() then
controlDelete
end if
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"
end openCard

on closeCard
// Delete the control when we leave the card
controlDelete
end closeCard

on controlDelete
// Delete the control
iphoneControlDelete "ioscontrol"
end controlDelete

Test in the simulator

video screen

Click on the simulate button to test.

About the Author

Ben Beaumont is Product Manager for RunRev Ltd.

 

Main Menu

What's New

sanjose