My RSS project used to do just that. It was for podcasts, but its the same call for a video stream. However when I redid the project, I just put up enough to get the RSS parser working and demoed, and didn’t include all the bits that made my app, well my app.
Here is the code I used for my project (basically the onClick row handler). Its director based and I’m using popup’s. I’m not going to provide the graphics or anything else, but you should be able to go figure out what I did and adapt it to your own.
[code]
– Abstract: Tab Bar sample app, example content screen
– Version: 1.0
– This file is used to display the corresponding screen content when the user clicks the tab bar.
module(…, package.seeall)
local widget = require(“widget”)
widget.setTheme(“theme_ios”)
function new()
local localGroup = display.newGroup()
local enclosures = story.enclosuers
local story = _G.story
local bg = display.newImageRect(“images/background.png”,320,480)
bg:setReferencePoint(display.TopLeftReferencePoint)
bg.x = 0
bg.y = 64
localGroup:insert(bg)
titleText:setText(pageTitle)
local myButton
local onButtonEvent = function (event )
if event.phase == “release” or event.phase == “ended” then
native.cancelWebPopup()
director:closePopUp()
end
return true
end
local myButton = ui.newButton{default=“images/backbutton.png”, over=“images/backbutton_over.png”, onRelease=onButtonEvent}
myButton.x = 40
myButton.y = 42
localGroup:insert(myButton)
local closedGroup = display.newGroup()
local openGroup = display.newGroup()
local function onComplete(event)
return true
end
local function playPodcast(target)
print(“playPodcast”)
media.playVideo( story.enclosures[1].url, media.RemoteSource, true, onComplete )
return true
end
local headlineBox = native.newTextBox( 0, 108, display.contentWidth, 60 )
headlineBox.text = story.title
headlineBox.align = “left”
headlineBox.hasBackground = false
headlineBox.font = native.newFont( “Helvetica-Bold”, 18 )
headlineBox:setTextColor(0,0,0,255)
localGroup:insert(headlineBox)
local path = system.pathForFile( “story.html”, system.TemporaryDirectory )
– io.open opens a file at path. returns nil if no file found
local fh, errStr = io.open( path, “w” )
if fh then
storyBody = story.content_encoded:gsub("([%w%s%p]+)", “%1”)
– print(storyBody)
– print( “Created file” )
fh:write("\n[html]\n\n")
fh:write("\n")
fh:write("\n html { -webkit-text-size-adjust: none; font-family: Helvetica, san-serif; font-size: 1.1em; } “)
fh:write(”\n\n")
fh:write( storyBody)
fh:write( “\n\n[/html]\n” )
io.close( fh )
else
print( “Create file failed!” )
end
local function listener(event)
– print(“showWebPopup callback”)
if event.errorMessage == nil then
local url = event.url
if( string.find( url, “http:” ) ~= nil or string.find( url, “mailto:” ) ~= nil ) then
– print("url: "… url)
system.openURL(url)
end
else
print(event.errorMessage)
end
return true
end
native.setActivityIndicator( false )
local options = { hasBackground=false, baseUrl=system.TemporaryDirectory, urlRequest=listener }
–local options = { hasBackground=true, urlRequest=listener }
– native.showWebPopup( 0, 170, display.contentWidth, display.contentHeight - (170 + 60), “http://www.robmiracle.com”, options )
native.cancelWebPopup()
native.showWebPopup(0, 170, display.contentWidth, 230, “story.html”, options )
if #story.enclosures > 0 then
local play_button = display.newImageRect(“images/play_button.png”, 200, 48)
play_button.x = display.contentWidth / 2
play_button.y = 430
localGroup:insert(play_button)
play_button:addEventListener(“tap”, playPodcast)
end
local adX, adY = 0, 60
if _G.appID then
ads.show( “banner320x50”, { x=adX, y=adY, interval=15 } )
end
function localGroup:clean()
native.cancelWebPopup()
end
return localGroup
end
[/code] [import]uid: 19626 topic_id: 18603 reply_id: 96953[/import]