Video Player
How to build Video Player?
Audio Player made in Script Language of DroidScript in very Easy with short codes. I give you an example but completely different in various method. buy the way, codes are never used in any program or app before I send it to my web post.
Thanks you for all Reader's.
Video Player version 2.0
Coding Start here....
app.SetOrientation( "Landscape" )
//Change this to your video folder.
app.SetScreenMode( "full" )
var folder = "/sdcard/Download";
//Called when application is started.
function OnStart()
{
//Show a progress dialog.
app.ShowProgress("Buffering...")
//Create layout that fills the screen.
lay = app.CreateLayout( "Linear", "FillX,Horizontal" )
lay.SetBackColor("#a1b2c3")
layB = app.CreateLayout( "Linear", "FillY,VBottom" )
laydrwr = app.CreateLayout( "Linear", "FillY,VBottom")
laydrwr.SetBackColor( "#cc22cc" )
layN = app.CreateLayout( "linear", "FillXY,VCenter" )
layN.SetBackColor( "#000000" )
laydrwr.SetSize(1,0.5 )
layN.SetOnTouch(ff_OnTouch)
//Create video view.
player = app.CreateVideoView( "Auto", "Auto")
layN.AddChild( player )
player.SetOnReady( player_OnReady )
player.SetOnComplete( player_OnComplete )
//Create video list.
spin = app.CreateSpinner( "[No videos found]" )
spin.SetSize( 0.8, -1 )
spin.SetOnTouch( spin_OnTouch )
laydrwr.AddChild( spin )
// Create videos list.
spn2 = app.CreateText( "Android Function" )
spn2.SetOnTouch( spn2_OnTouch )
laydrwr.AddChild( spn2 )
//00000000000000000000000000000000000000
//Create 'Play' button.
btnPlay = app.CreateButton("[fa-play]",0.1,0.15,"FontAwesome")
btnPlay.SetBackColor( "#cc22cc" )
btnPlay.SetTextColor( "#22ff22" )
btnPlay.SetOnTouch( btnPlay_OnTouch )
lay.AddChild( btnPlay )
//Create 'Pause' button.
btnPause = app.CreateButton("[fa-pause]",0.1,0.15,"FontAwesome")
btnPause.SetBackColor("#cc22cc")
btnPause.SetTextColor( "#22ff22" )
btnPause.SetOnTouch( btnPause_OnTouch )
lay.AddChild( btnPause )
//Create 'Stop' button.
btnStop = app.CreateButton("[fa-stop]",0.1,0.15,"FontAwesome")
btnStop.SetBackColor("#cc22cc")
btnStop.SetTextColor( "#22ff22" )
btnStop.SetOnTouch( btnStop_OnTouch )
lay.AddChild( btnStop )
//Button New
btnSet = app.CreateButton("[fa-home]",0.1,0.15,"FontAwesome")
btnSet.SetBackColor("#cc22cc")
btnSet.SetTextColor( "#22ff22" )
btnSet.SetOnTouch( btnSet_OnTouch )
lay.AddChild( btnSet )
//file Open btn
btnFol2 = app.CreateButton("[fa-file]",0.1,0.15,"FontAwesome")
btnFol2.SetTextColor( "#22ff22" )
btnFol2.SetOnTouch( btnFile_OnTouch )
lay.AddChild( btnFol2)
// Color filter Swirch
btnSwitch= app.CreateButton("[fa-close]",0.1,0.15,"FontAwesome")
btnSwitch.SetBackColor("#cc22cc")
btnSwitch.SetTextColor( "red" )
btnSwitch.SetOnTouch( btnSwitch_OnTouch )
lay.AddChild( btnSwitch)
//Create seek bar and add to layout.
skb = app.CreateSeekBar(1.9, -1 )
skb.SetMargins( 0, 0.05, 0, 0)
skb.SetRange( 1.0 )
skb.SetOnTouch( skb_OnTouch )
layB.AddChild( skb )
//zoom for webpage
txtZoom = app.CreateText( "Brightness Control")
txtZoom.SetTextColor( "#22ff22" )
laydrwr.AddChild( txtZoom )
//seekbar one
btnZoom = app.CreateSeekBar( 0.8,0.1)
btnZoom.SetRange(1)
btnZoom.SetOnTouch( btnZoom_OnTouch )
laydrwr.AddChild(btnZoom)
//color for webpage
txtColr= app.CreateText( "Volume Control" )
txtColr.SetTextColor( "#22ff22" )
laydrwr.AddChild( txtColr)
//seekbar one
btnColr= app.CreateSeekBar( 0.8,0.1)
btnColr.SetRange(1)
btnColr.SetOnTouch( btnColr_OnTouch )
laydrwr.AddChild(btnColr)
//Add main layout to app.
app.AddLayout( layN)
app.AddLayout( layB)
app.AddLayout( lay)
app.AddLayout( laydrwr )
laydrwr.Hide()
//Find first ten mp4 files on internal sdcard.
mp4List = app.ListFolder(folder,".", 999)
spin.SetList( mp4List )
app.HideProgress()
//Load the first file found.
player.SetFile(folder + "/" + spin.GetText() )
dur = null;
//Start timer to update seek bar every second.
setInterval( "Update()", 3000 )
}
//Called when user touches our 'Choose File' button.
function btnFile_OnTouch()
{
app.ChooseFile( "Choose a file", "*/*", OnFileChoose )
}
//Called when a file is chosen.
function OnFileChoose( file)
{
player.SetFile(file)
app.ShowPopup( fileName )
}
function spn2_OnTouch()
{
laydrwr.Hide();
// setInterval("laydrwr.Hide()",3000)
}
//hide and seek
function ff_OnTouch()
{
layB.Show()
lay.Show()
}
//Called when file is ready to play.
function player_OnReady()
{
player.Stop()
}
//Called when playback has finished.
function player_OnComplete()
{
app.ShowPopup( "Finished" )
}
//Handle file select.
function spin_OnTouch( item)
{
player.SetFile( folder+ "/" + item)
}
//Handle 'Play' button.
function btnPlay_OnTouch()
{
player.Play()
layB.Hide()
lay.Hide()
}
//Handle 'Pause' button.
function btnPause_OnTouch()
{
player.Pause()
}
//Handle 'Stop' button.
function btnStop_OnTouch()
{
player.Stop()
}
function btnSet_OnTouch()
{
laydrwr.Show();
}
function btnZoom_OnTouch(level)
{
app.SetScreenBrightness( level)
}
function btnColr_OnTouch(value)
{
app.SetVolume( "Music",value )
}
//Called when user touches the seek bar.
function skb_OnTouch( value )
{
player.SeekTo( dur * value )
}
//Update seek bar.
function Update()
{
dur = player.GetDuration()
prog = player.GetPosition()
if( dur ) skb.SetValue( prog / dur )
}
function btnSwitch_OnTouch()
{
app.Quit( "Are You Want to Quit","Easy Player")
}
0 Comments