چطوری یه صوت از دیتابیس آنلاین فراخوانی و دانلود کنم و به صورت آفلاین پخش کنم؟
با تشکر
Type=Activity
Version=6.3
ModulesStructureVersion=1
B4A=true
@EndOfDesignText@
#Region Activity Attributes
#FullScreen: true
#IncludeTitle: false
#End Region
Sub Process_Globals
Dim Timer1 As Timer
End Sub
Sub Globals
Private btnplayandpause As Button
Dim Obj1 As Reflector
Private Label1 As Label
Private ScrollView1 As ScrollView
Dim mm As StringUtils
Dim cursor1 As Cursor
Dim ht1,ft1 As Float
Private Button2 As Button
Dim dlColor As ColorPickerDialog
Private Button1 As Button
Dim audio As MediaPlayer
Dim bitmap2,bitmap3 As Bitmap
Private Button3 As Button
Private SeekBar1 As SeekBar
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("khandan")
Dim p As PhoneWakeState
p.KeepAlive(True)
If File.Exists(File.DirInternal,"doarezg.db") = False Then
File.Copy(File.DirAssets,"doarezg.db",File.DirInternal,"doarezg.db")
End If
If fehrestdastanha.sql1.IsInitialized = False Then
fehrestdastanha.sql1.Initialize(File.DirInternal,"doarezg.db",False)
End If
cursor1=fehrestdastanha.sql1.ExecQuery("SELECT * FROM mytable WHERE list='" & fehrestdastanha.khandanmatalb & "'")
For i=0 To cursor1.RowCount-1
cursor1.Position=i
Label1.Initialize("")
Label1.Text = cursor1.GetString("Matn")
Label1.TextColor=Colors.black
Label1.TextSize=16
Button1.Tag=i
audio.Initialize()
audio.Load(File.DirAssets,cursor1.GetString("ahang"))
Timer1.Initialize("timer1", 10000)
Timer1.Enabled=True
ScrollView1.Panel.AddView(Label1,0,0,ScrollView1.Width-6,ScrollView1.Height)
'------------------------------
Obj1.Target = Label1
Obj1.RunMethod3("setLineSpacing",1, "java.lang.float", 1.3, "java.lang.float")
ht1 =mm.MeasureMultilineTextHeight(Label1,Label1.Text)
ft1=ht1 * 2.1
'------------------------------
Label1.Height = ft1
ScrollView1.Panel.Height=ft1
'====================================================================================
Try
Label1.TextSize = code.getData("setting_cheshmzakhm.txt","FontSize")
Label1.TextColor = code.getData("setting_cheshmzakhm.txt","FontColor")
fehrestdastanha.khandanmatalb= code.getData("setting_cheshmzakhm.txt","FontColor")
Label1.Typeface=Typeface.LoadFromAssets(code.getData("setting_cheshmzakhm.txt","Font"))
Obj1.Target = Label1
Obj1.RunMethod3("setLineSpacing",1, "java.lang.float", 1.3, "java.lang.float")
ht1 =mm.MeasureMultilineTextHeight(Label1,Label1.Text)
ft1=ht1 * 2.1
'------------------------------
Label1.Height = ft1
ScrollView1.Panel.Height=ft1
Catch
Obj1.Target = Label1
Obj1.RunMethod3("setLineSpacing",1, "java.lang.float", 2.0, "java.lang.float")
ht1 =mm.MeasureMultilineTextHeight(Label1,Label1.Text)
ft1=ht1 * 2.1
'------------------------------
Label1.Height = ft1
ScrollView1.Panel.Height=ft1
'===================================================================================
fehrestdastanha.khandanmatalb=0
End Try
'====================================================================================
Next
dlColor.RGB= Colors.Black
bitmap2.Initialize(File.DirAssets,"play1.png")
bitmap3.Initialize(File.DirAssets,"pause1.png")
Dim b1 As Bitmap
b1.Initialize(File.DirAssets,"star"&cursor1.GetString("Fav")&".png")
Button1.SetBackgroundImage(b1)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnplayandpause_Click
If audio.IsPlaying Then
audio.Pause
btnplayandpause.SetBackgroundImage(bitmap2)
Else
audio.Play
btnplayandpause.SetBackgroundImage(bitmap3)
End If
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
audio.Stop
btnplayandpause.SetBackgroundImage(bitmap3)
End If
End Sub
Sub Button1_Click
Dim btn As Button
btn=Sender
cursor1.Position = btn.Tag
Dim check As Int
check = cursor1.GetString("Fav")
If check = 1 Then
fehrestdastanha.sql1.ExecNonQuery("UPDATE mytable SET Fav = 0 WHERE id = "&cursor1.GetInt("id"))
fehrestdastanha.sql1.IsInitialized
cursor1 = fehrestdastanha.sql1.ExecQuery("SELECT * FROM mytable")
Dim b As Bitmap
b.Initialize(File.DirAssets,"star0.png")
Button1.SetBackgroundImage(b)
ToastMessageShow("از علاقه مندی ها حذف شد",False)
Else
fehrestdastanha.sql1.ExecNonQuery("UPDATE mytable SET Fav = 1 WHERE id = "&cursor1.GetInt("id"))
fehrestdastanha.sql1.IsInitialized
cursor1 = fehrestdastanha.sql1.ExecQuery("SELECT * FROM mytable")
Dim b As Bitmap
b.Initialize(File.DirAssets,"star1.png")
Button1.SetBackgroundImage(b)
ToastMessageShow("به علاقه مندی ها اضافه شد",False)
End If
End Sub
Sub Button2_Click
Dim i As Intent
Dim a As String
a = cursor1.GetString("Matn")
i.Initialize(i.ACTION_SEND, "")
i.SetType("text/plain")
i.PutExtra("android.intent.extra.TEXT",a)
i.WrapAsIntentChooser("ارسال از طریق...")
StartActivity(i)
End Sub
Sub Button4_Click
Dim i As Intent
Dim a As String
a=cursor1.GetString("Matn")
i.Initialize(i.ACTION_VIEW, "sms:")
i.PutExtra("sms_body",a)
StartActivity(i)
End Sub
Sub Button3_Click
StartActivity(frmsetting)
End Sub
Sub timer1_Tick
If audio.IsPlaying Then
SeekBar1.Value = audio.Position / audio.Duration * 10000
End If
End Sub
Sub SeekBar1_ValueChanged (Value As Int, UserChanged As Boolean)
If UserChanged = False Then Return
audio.Position = Value / 10000 * audio.Duration
timer1_Tick
End Sub
سوال
sajadkharestani 25
سلام
چطوری یه صوت از دیتابیس آنلاین فراخوانی و دانلود کنم و به صورت آفلاین پخش کنم؟
با تشکر
Type=Activity Version=6.3 ModulesStructureVersion=1 B4A=true @EndOfDesignText@ #Region Activity Attributes #FullScreen: true #IncludeTitle: false #End Region Sub Process_Globals Dim Timer1 As Timer End Sub Sub Globals Private btnplayandpause As Button Dim Obj1 As Reflector Private Label1 As Label Private ScrollView1 As ScrollView Dim mm As StringUtils Dim cursor1 As Cursor Dim ht1,ft1 As Float Private Button2 As Button Dim dlColor As ColorPickerDialog Private Button1 As Button Dim audio As MediaPlayer Dim bitmap2,bitmap3 As Bitmap Private Button3 As Button Private SeekBar1 As SeekBar End Sub Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("khandan") Dim p As PhoneWakeState p.KeepAlive(True) If File.Exists(File.DirInternal,"doarezg.db") = False Then File.Copy(File.DirAssets,"doarezg.db",File.DirInternal,"doarezg.db") End If If fehrestdastanha.sql1.IsInitialized = False Then fehrestdastanha.sql1.Initialize(File.DirInternal,"doarezg.db",False) End If cursor1=fehrestdastanha.sql1.ExecQuery("SELECT * FROM mytable WHERE list='" & fehrestdastanha.khandanmatalb & "'") For i=0 To cursor1.RowCount-1 cursor1.Position=i Label1.Initialize("") Label1.Text = cursor1.GetString("Matn") Label1.TextColor=Colors.black Label1.TextSize=16 Button1.Tag=i audio.Initialize() audio.Load(File.DirAssets,cursor1.GetString("ahang")) Timer1.Initialize("timer1", 10000) Timer1.Enabled=True ScrollView1.Panel.AddView(Label1,0,0,ScrollView1.Width-6,ScrollView1.Height) '------------------------------ Obj1.Target = Label1 Obj1.RunMethod3("setLineSpacing",1, "java.lang.float", 1.3, "java.lang.float") ht1 =mm.MeasureMultilineTextHeight(Label1,Label1.Text) ft1=ht1 * 2.1 '------------------------------ Label1.Height = ft1 ScrollView1.Panel.Height=ft1 '==================================================================================== Try Label1.TextSize = code.getData("setting_cheshmzakhm.txt","FontSize") Label1.TextColor = code.getData("setting_cheshmzakhm.txt","FontColor") fehrestdastanha.khandanmatalb= code.getData("setting_cheshmzakhm.txt","FontColor") Label1.Typeface=Typeface.LoadFromAssets(code.getData("setting_cheshmzakhm.txt","Font")) Obj1.Target = Label1 Obj1.RunMethod3("setLineSpacing",1, "java.lang.float", 1.3, "java.lang.float") ht1 =mm.MeasureMultilineTextHeight(Label1,Label1.Text) ft1=ht1 * 2.1 '------------------------------ Label1.Height = ft1 ScrollView1.Panel.Height=ft1 Catch Obj1.Target = Label1 Obj1.RunMethod3("setLineSpacing",1, "java.lang.float", 2.0, "java.lang.float") ht1 =mm.MeasureMultilineTextHeight(Label1,Label1.Text) ft1=ht1 * 2.1 '------------------------------ Label1.Height = ft1 ScrollView1.Panel.Height=ft1 '=================================================================================== fehrestdastanha.khandanmatalb=0 End Try '==================================================================================== Next dlColor.RGB= Colors.Black bitmap2.Initialize(File.DirAssets,"play1.png") bitmap3.Initialize(File.DirAssets,"pause1.png") Dim b1 As Bitmap b1.Initialize(File.DirAssets,"star"&cursor1.GetString("Fav")&".png") Button1.SetBackgroundImage(b1) End Sub Sub Activity_Resume End Sub Sub Activity_Pause (UserClosed As Boolean) End Sub Sub btnplayandpause_Click If audio.IsPlaying Then audio.Pause btnplayandpause.SetBackgroundImage(bitmap2) Else audio.Play btnplayandpause.SetBackgroundImage(bitmap3) End If End Sub Sub Activity_KeyPress (KeyCode As Int) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then audio.Stop btnplayandpause.SetBackgroundImage(bitmap3) End If End Sub Sub Button1_Click Dim btn As Button btn=Sender cursor1.Position = btn.Tag Dim check As Int check = cursor1.GetString("Fav") If check = 1 Then fehrestdastanha.sql1.ExecNonQuery("UPDATE mytable SET Fav = 0 WHERE id = "&cursor1.GetInt("id")) fehrestdastanha.sql1.IsInitialized cursor1 = fehrestdastanha.sql1.ExecQuery("SELECT * FROM mytable") Dim b As Bitmap b.Initialize(File.DirAssets,"star0.png") Button1.SetBackgroundImage(b) ToastMessageShow("از علاقه مندی ها حذف شد",False) Else fehrestdastanha.sql1.ExecNonQuery("UPDATE mytable SET Fav = 1 WHERE id = "&cursor1.GetInt("id")) fehrestdastanha.sql1.IsInitialized cursor1 = fehrestdastanha.sql1.ExecQuery("SELECT * FROM mytable") Dim b As Bitmap b.Initialize(File.DirAssets,"star1.png") Button1.SetBackgroundImage(b) ToastMessageShow("به علاقه مندی ها اضافه شد",False) End If End Sub Sub Button2_Click Dim i As Intent Dim a As String a = cursor1.GetString("Matn") i.Initialize(i.ACTION_SEND, "") i.SetType("text/plain") i.PutExtra("android.intent.extra.TEXT",a) i.WrapAsIntentChooser("ارسال از طریق...") StartActivity(i) End Sub Sub Button4_Click Dim i As Intent Dim a As String a=cursor1.GetString("Matn") i.Initialize(i.ACTION_VIEW, "sms:") i.PutExtra("sms_body",a) StartActivity(i) End Sub Sub Button3_Click StartActivity(frmsetting) End Sub Sub timer1_Tick If audio.IsPlaying Then SeekBar1.Value = audio.Position / audio.Duration * 10000 End If End Sub Sub SeekBar1_ValueChanged (Value As Int, UserChanged As Boolean) If UserChanged = False Then Return audio.Position = Value / 10000 * audio.Duration timer1_Tick End Sub
لینک ارسال
به اشتراک گذاری در سایت های دیگر
0 پاسخ به این سوال تاکنون داده شده است
ارسالهای توصیه شده
بایگانی شده
این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.