Simple Audio Stream App Issues

Rossage99

Member
Licensed User
Longtime User
Hi all,

I'm in the process of making my first app, so consider me uneducated.

I've bashed my way through making a very basic app to stream my podcast. After trying for some time to construct an in-app stream/player (and failing miserably) I settled on a straight URL to the flash player on my site. The only problem being, when the file streams it has no audio. I know there is no problem with the streaming through my PC browser, so the issue must be with the app.

So my question is two-fold:
1) is there an obvious way to create a simple audio file stream in-app that I've just overlooked?
if not:
2) any ideas as to why I'm not getting any audio?


Let me know if any of my code would be useful to have posted here as well.

Thanks in advance.
 

Rossage99

Member
Licensed User
Longtime User
I did check out MediaPlayerStream but couldn't fathom how to implement it properly with my limited knowledge.

Here's all my code:

B4X:
'Activity module
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim btnPlayEp As Button
   Dim btnSite As Button
   Dim lblLogo As Label
   Dim wvIIMCI As WebView
   Dim btnFb As Button
   Dim btnTwitter As Button
   Dim btnBack As Button
   Dim pnlSite As Panel
   Dim pnlMain As Panel
   Dim btnBack2 As Button
   Dim pnlPlayer As Panel
   Dim btnPlay1 As Button
   Dim bntPlay5 As Button
   Dim btnPlay2 As Button
   Dim btnPlay3 As Button
   Dim btnPlay4 As Button
   Dim btnCredits As Button
   Dim btnBack3 As Button
   Dim pnlCredits As Panel
End Sub
Sub Process_Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("Main")
End Sub
Sub New
  btnPlayEp.Color = Colors.RGB(0,0,0)
   btnSite.Color = Colors.RGB(0,0,0)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub btnPlayEp_Click
   Activity.LoadLayout("player")
   End Sub
Sub btnSite_Click
Activity.LoadLayout("webview")
     wvIIMCI.Width = 100%x
    wvIIMCI.Height = 80%y
      wvIIMCI.LoadURL("http://ifitmovescritiqueit.podomatic.com/")
End Sub
Sub btnTwitter_Click
Activity.LoadLayout("webview")
    wvIIMCI.Width = 100%x
    wvIIMCI.Height = 80%y
      wvIIMCI.LoadURL("https://twitter.com/#!/IIMCI")
End Sub
Sub btnFb_Click
Activity.LoadLayout("webview")
     wvIIMCI.Width = 100%x
    wvIIMCI.Height = 80%y
      wvIIMCI.LoadURL("http://www.facebook.com/IIMCI")
End Sub
Sub btnBack_Click
   pnlMain.BringToFront
   pnlSite.SendToBack
End Sub
Sub btnBack2_Click
      pnlMain.BringToFront
     pnlPlayer.SendToBack
End Sub
Sub btnPlay1_Click
   Activity.LoadLayout("webview")
     wvIIMCI.Width = 100%x
    wvIIMCI.Height = 80%y
      wvIIMCI.LoadURL("http://ifitmovescritiqueit.podomatic.com/player/web/2012-01-26T05_13_24-08_00")
End Sub
Sub btnPlay2_Click
      Activity.LoadLayout("webview")
     wvIIMCI.Width = 100%x
    wvIIMCI.Height = 80%y
      wvIIMCI.LoadURL("http://ifitmovescritiqueit.podomatic.com/player/web/2012-02-27T17_51_04-08_00")
End Sub
Sub btnPlay3_Click
      Activity.LoadLayout("webview")
     wvIIMCI.Width = 100%x
    wvIIMCI.Height = 80%y
      wvIIMCI.LoadURL("http://ifitmovescritiqueit.podomatic.com/player/web/2012-03-15T17_41_22-07_00")
End Sub
Sub btnPlay4_Click
      Activity.LoadLayout("webview")
     wvIIMCI.Width = 100%x
    wvIIMCI.Height = 80%y
      wvIIMCI.LoadURL("http://ifitmovescritiqueit.podomatic.com/player/web/2012-04-10T14_51_26-07_00")
End Sub
Sub bntPlay5_Click
      Activity.LoadLayout("webview")
     wvIIMCI.Width = 100%x
    wvIIMCI.Height = 80%y
      wvIIMCI.LoadURL("http://ifitmovescritiqueit.podomatic.com/player/web/2012-04-27T08_11_43-07_00")
End Sub
Sub btnCredits_Click
   Activity.LoadLayout("credits")
End Sub
Sub btnBack3_Click
      pnlMain.BringToFront
     pnlCredits.SendToBack
End Sub
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
Well, for future reference, if you have a project with layouts and files it would be better to attach the whole project, that way we can take a look at the whole code, to do that, from the IDE click on File -> Export as ZIP.

I know you are learning, so, commenting your code would confuse you, so, in order to make you understand this B4A business, take a look at the attached project, it plays one of your podcasts using MediaPlayerStream.

If you have more questions, well, here we are. :)
 

Attachments

  • PodcastSample.zip
    7.1 KB · Views: 639
Last edited:
Upvote 0

Rossage99

Member
Licensed User
Longtime User
Wow, thank you! that's so much of what I was looking for in such a simple format, it made it very easy to actually understand what code was doing what, so I knew what I was writing and not just C+P'ing stuff!

There's one issue that I can't seem to fathom, and it's the same issue I ran into when I tried using MediaPlayerStream before: all instances of "mp" and "MediaPlayerStream" in my code are highlighted in red, but in the code for the file you attached they're not.

I've tried comparing the two but can't seem to find the difference...
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
...when I tried using MediaPlayerStream before: all instances of "mp" and "MediaPlayerStream" in my code are highlighted in red...

That means you haven't referenced the AUDIO library in the IDE, on the bottom right hand panel you'll see a series of tabs, one is called LIBS, you have you check the libs needed, my sample already has that.
 
Upvote 0

Rossage99

Member
Licensed User
Longtime User
Thank you so much, everything on the Lite version now works as well as can be expected!

Your help was much appreciated
 
Upvote 0

sally3599

Member
Licensed User
Longtime User
how to put 2nd mp3 url in the playlist?

Hello NJDude,
I add two lines in the PodcastSample.zip
B4X:
mp.Load("http://website/my.mp3")
mp.Load("http://website/my2.mp3")
mp.looping = True
but it plays my2.mp3 only, can I add more mp3 url and play in sequence?
 
Upvote 0

cambopad

Active Member
Licensed User
Longtime User
That means you haven't referenced the AUDIO library in the IDE, on the bottom right hand panel you'll see a series of tabs, one is called LIBS, you have you check the libs needed, my sample already has that.

@NJDude I downloaded your code and then tested it on the real device. I can press "Listen Podcast" then the podcast started to play. However, when I press the power button to lock the screen. The podcast stop playing! After that, I unlock the screen and press on "Stop". Surprisingly, I got this message "
MEDIA_ERROR_UNKNOWN"?????

How can I solve this issue? The issue seem to occur only when the phone screen is locked and unlocked!
 
Upvote 0
Top