hi
i have this b4a code which i thougth it is not nice and that it would be better if i put a remote sever database the code will be shorter and better but i am stuk in the way i must thing to do this, php code works
here is the b4a code and the php code
and i try to convert it to a database with 3 fealds
rdstream,rdname,rdimage
my php code is
what i try to do if i dont make it clear is to use remote database where i store the radio station secription, stream,and image in stead the way i have it now, i will appreciate your help
i have this b4a code which i thougth it is not nice and that it would be better if i put a remote sever database the code will be shorter and better but i am stuk in the way i must thing to do this, php code works
here is the b4a code and the php code
B4X:
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim mp As MediaPlayerStream
End Sub
Sub Globals
Private BannerAd As AdView
Private IAd As InterstitialAd
'Dim ImageView1 As ImageView
Dim Label1 As Label
'Dim Panel1 As Panel
'Dim Panel2 As Panel
Dim Button1 As Button
Dim State As Int
Dim Url As String
Dim ListView1 As ListView
Dim Station As String
Dim UrlDefiner As Int
Dim Bitmap1 As Bitmap
Dim Bitmap2 As Bitmap
Dim Bitmap3 As Bitmap
Dim Bitmap4 As Bitmap
Dim Bitmap5 As Bitmap
Dim Button1 As Button
Dim Button2 As Button
Dim Button3 As Button
'Dim INPhoneNumber As String
'Dim INText As String
Bitmap1.Initialize(File.DirAssets, "1.jpg")
Bitmap2.Initialize(File.DirAssets, "2.jpg")
Bitmap3.Initialize(File.DirAssets, "3.jpg")
Bitmap4.Initialize(File.DirAssets, "4.jpg")
Bitmap5.Initialize(File.DirAssets, "5.jpg")
Dim Stream(36) As String
Stream(1) = "http://examplestream/;listen.pls" ' RB
Stream(2) = "http://examplestream:8081/listen.mp3" ' ambient
Stream(3) = "http://examplestream/;listen.pls" ' classic mix
Stream(4) = "http://examplestream:8081/listen.mp3" ' eighties
Stream(5) = "http://examplestream:8104/stream" ' current top 40
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout1")
ListView1.TwoLinesAndBitmap.Label.TextSize= "14"
ListView1.AddTwoLinesAndBitmap("radio descreption1", "", Bitmap1)
ListView1.AddTwoLinesAndBitmap("radio descreption2", "", Bitmap2)
ListView1.AddTwoLinesAndBitmap("radio descreption3", "", Bitmap3)
ListView1.AddTwoLinesAndBitmap("radio descreption4", "", Bitmap4)
ListView1.AddTwoLinesAndBitmap("radio descreption5", "", Bitmap5)
ListView1.AddSingleLine(" ")
If FirstTime Then
mp.Initialize("mp")
End If
Label1.Text = "Click a Station to Listen"
End Sub
Sub mp_StreamReady
Log("starts playing")
mp.Play
Label1.Text = "Playing - " & Station
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
Sub Stop_Click
Log("stop playing")
mp.Stop
State = 2
Label1.Text = "Click a Station to Listen"
End Sub
Sub ListView1_ItemClick (Position As Int, Value As Object)
Station = Value
UrlDefiner = Position + 1
If State = 1 Then Stop_Click
Url = Stream(UrlDefiner)
mp.Load(Url)
State = 1
Label1.Text = "Buffering"
End Sub
Sub Button1_Click
If State = 1 Then Stop_Click
End Sub
and i try to convert it to a database with 3 fealds
rdstream,rdname,rdimage
my php code is
PHP:
<?php
$host = "localhost";
$db = "mydbname";
$user = "mydbuser";
$pw = "mydbuserpassword";
$con = mysql_connect($host,$user,$pw) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET NAMES 'utf8'");
$sql = "SELECT rdstream, rdname, rdimage FROM tbl_radiostations";
$res = mysql_query($sql);
if (mysql_errno()) {
header("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysql_error();
}
else
{
$rows = array();
while($r = mysql_fetch_assoc($res)) {
$rows[] = $r;
}
print json_encode($rows);
}
?>
what i try to do if i dont make it clear is to use remote database where i store the radio station secription, stream,and image in stead the way i have it now, i will appreciate your help