Book Image

LiveCode Mobile Development Beginner's Guide (2nd Edition)

Book Image

LiveCode Mobile Development Beginner's Guide (2nd Edition)

Overview of this book

Table of Contents (15 chapters)
LiveCode Mobile Development Beginner's Guide Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – extracting a list of media links


There probably is a regular expression that would extract all the src links from a page, but we're only interested in things that we know LiveCode is able to show or play. So in these steps, we'll use a more devious way to extract just the links we can handle:

  1. You may as well head over to the test stack!

  2. Make a third button by duplicating one of the other two and change the getLinks or getText part in the button script to call getMedia instead.

  3. In the stack script, enter all of this:

    global gPageURL
    
    function getMedia pPageSource
      put ".jpg,.png,.gif,.jpeg,.mov,.mp4,m4v,.mp3" into tExtensions
      repeat with a = 1 to the number of items in tExtensions
        put item a of tExtensions into tExtension
        replace tExtension with tExtension & "*" & return in pPageSource
      end repeat
      repeat with a = the number of lines in pPageSource down to 1
        put line a of pPageSource into tLine
        if the last char of tLine is "*" then
          delete the...