Keeping App running after screens timeouts

mikejohnsonharp

Member
Licensed User
Longtime User
ListView of mp3 in MediaPlayerStream from website

Hi Erel,
I'm wanting to put a number of my mp3s from my website in a ListView Page
I have used the example that NJDude gave on the thread "Stream media from link within WebView"
That example gives one specific online location rather than a list of many online locations for mp3s which could be presented and then played, maybe with a picture of the album cover..ie
'1st song (with Album cover)
WebView1.LoadHtml("<a href='http://www.michaeljohnson.com.au/samples-mobi/song1-1.mp3'>Free</a>")
'2nd song (with Album cover)
WebView1.LoadHtml("<a href='http://www.michaeljohnson.com.au/samples-mobi/song1-2.mp3'>Chill</a>")


Thanks in advance
Michael
 
Last edited:

mikejohnsonharp

Member
Licensed User
Longtime User
Hi Again Erel,
Here's the modified ListView example with all of the songs on my website

Activity module

Sub Process_Globals

'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.

End Sub

Sub Globals

'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

Dim web As PhoneIntents
Dim ListView1 As ListView

End Sub

Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("Main")

ListView1.AddTwoLinesAndBitmap2("Free", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-1.mp3")
ListView1.AddTwoLinesAndBitmap2("Chill", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-2.mp3")
ListView1.AddTwoLinesAndBitmap2("Breath", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-3.mp3")
ListView1.AddTwoLinesAndBitmap2("Bridge", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-4.mp3")
ListView1.AddTwoLinesAndBitmap2("Swan", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-5.mp3")
ListView1.AddTwoLinesAndBitmap2("Roar", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-6.mp3")
ListView1.AddTwoLinesAndBitmap2("Forest", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-7.mp3")
ListView1.AddTwoLinesAndBitmap2("Labyrinth", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-8.mp3")


End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause(UserClosed As Boolean)

End Sub

Sub Listview1_ItemClick (Position As Int, Value As Object)

ListView1.GetItem(Position)

StartActivity(web.OpenBrowser(ListView1.GetItem(Position)))

End Sub


It would look like this
SC20120924-185048.png


This example would just send the user via a browser to these sites.
Instead, Im wanting to stay on that page and have the mp3 music streamed via MediaPlayerStream like in the NJDudes example.
Is this possible?
 
Upvote 0

mikejohnsonharp

Member
Licensed User
Longtime User
moving from list view to medialplayerstream

Sorry Erel,
I'm new to Basic4Android.
Can you suggest code that would take me from the listview above to a mediaplayerstream rather than a webview activity so I could stay on the listview page and here the mp3s I clicked?
Thanks in advance
 
Upvote 0

mikejohnsonharp

Member
Licensed User
Longtime User
Hi Erel,
I got this far and don't know where to go from here...
I think this is the right way but having difficulty loading the stream
"Listview1_ItemClick (Position As Int, Value As MediaPlayerStream)
mp.Load.... "
Can you help??
Thanks in advance
Mike

Sub Process_Globals
Dim mp As MediaPlayerStream
End Sub
.....
Sub Globals
Dim web As PhoneIntents
Dim ListView1 As ListView
End Sub
......
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")

If FirstTime Then
mp.Initialize("mp")
End If
ListView1.AddTwoLinesAndBitmap2("Free", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-1.mp3")
ListView1.AddTwoLinesAndBitmap2("Chill", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-2.mp3")
ListView1.AddTwoLinesAndBitmap2("Breath", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-3.mp3")
ListView1.AddTwoLinesAndBitmap2("Bridge", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-4.mp3")
ListView1.AddTwoLinesAndBitmap2("Swan", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-5.mp3")
ListView1.AddTwoLinesAndBitmap2("Roar", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-6.mp3")
ListView1.AddTwoLinesAndBitmap2("Forest", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-7.mp3")
ListView1.AddTwoLinesAndBitmap2("Labyrinth", "Dancing in the Garden", LoadBitmap(File.DirAssets,"dancing.jpg"),"http://www.michaeljohnson.com.au/samples-mobi/song1-8.mp3")

End Sub
........
Sub Listview1_ItemClick (Position As Int, Value As MediaPlayerStream)
mp.Load

'THIS IS WHERE I"M STUCK AS FAR AS CALLING THE STREAMER FROM THE LISTVIEW

End Sub
..........
Sub mp_StreamReady
Log("starts playing")
mp.Play
End Sub
......
Sub mp_StreamError (ErrorCode As String, ExtraData As Int)
Log("Error: " & ErrorCode & ", " & ExtraData)
ToastMessageShow("Error: " & ErrorCode & ", " & ExtraData, True)
End Sub
.....
Sub mp_StreamBuffer(Percentage As Int)
Log(Percentage)
End Sub
 
Upvote 0
Top