آقا من میخوام چندتا صوت آفلاین رو فراخونی کنم دو تا مشکل دارم
1-وقتی با فرمت(mp3)کار میکنم فایل بخش میشه اما وقتی که با فرمت مورد نیازم(wma)کار میکنم خطای زیر رو میده
2-وقتی که وسط بخش بر رو stopمیزنم بعدش هم فایل رو دوباره play میکنم از اول شروع میشه
Sub Process_Globals
Dim SQL As SQL
Dim timer1 As Timer
End Sub
Sub Globals
Dim cr As Cursor
Dim i As Int:i=0
Private lblword As Label
Private imgnex As ImageView
Dim MediaPlayer1 As MediaPlayer
Private btnsot As Button
Dim barPosition As SeekBar
Dim barVolume As SeekBar
Dim lblPosition As Label
Dim Looping As ToggleButton
Private imgback As ImageView
Private imgpause As ImageView
Private imgplay As ImageView
Private imgstop As ImageView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("dors_soty")
If File.Exists(File.DirInternal,"Textonee.db")=False Then
File.Copy(File.DirAssets,"Textonee.db",File.DirInternal,"Textonee.db")
End If
SQL.Initialize(File.DirInternal,"Textonee.db",False)
timer1.Initialize("timer1", 1000)
Try
cr=SQL.ExecQuery("SELECT*FROM sqldataa")
cr.Position=i
lblword.Text=cr.GetString("sot")
Catch
End Try
MediaPlayer1.Initialize( )
MediaPlayer1.Load(File.DirAssets, lblword.Text)
End Sub
Sub imgnex_Click
imgpause.Visible=False
imgplay.Visible=True
If MediaPlayer1.IsPlaying Then
MediaPlayer1.stop
End If
i=i+1
Try
cr=SQL.ExecQuery("SELECT*FROM sqldataa")
cr.Position=i
lblword.Text=cr.GetString("sot")
Catch
End Try
End Sub
Sub imgback_Click
imgpause.Visible=False
imgplay.Visible=True
If MediaPlayer1.IsPlaying Then
MediaPlayer1.stop
End If
i=i-1
Try
cr=SQL.ExecQuery("SELECT*FROM sqldataa")
cr.Position=i
lblword.Text=cr.GetString("sot")
Catch
End Try
End Sub
Sub imgplay_Click
MediaPlayer1.Initialize2("")
MediaPlayer1.Load(File.DirAssets, lblword.Text)
MediaPlayer1.play
imgpause.Visible=True
imgplay.Visible=False
End Sub
Sub Activity_Resume
timer1.Enabled = True
timer1_Tick
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If MediaPlayer1.IsPlaying Then MediaPlayer1.Pause
timer1.Enabled = False
End Sub
Sub timer1_Tick
If MediaPlayer1.IsPlaying Then
barPosition.Value = MediaPlayer1.Position / MediaPlayer1.Duration * 100
lblPosition.Text = "Position: " & ConvertToTimeFormat(MediaPlayer1.Position) & _
" (" & ConvertToTimeFormat(MediaPlayer1.Duration) & ")"
End If
End Sub
Sub ConvertToTimeFormat(ms As Int) As String
Dim seconds, minutes As Int
seconds = Round(ms / 1000)
minutes = Floor(seconds / 60)
seconds = seconds Mod 60
Return NumberFormat(minutes, 1, 0) & ":" & NumberFormat(seconds, 2, 0) 'ex: 3:05
End Sub
Sub barVolume_ValueChanged (Value As Int, UserChanged As Boolean)
MediaPlayer1.SetVolume(barVolume.Value / 100, barVolume.Value / 100)
End Sub
Sub barPosition_ValueChanged (Value As Int, UserChanged As Boolean)
If UserChanged = False Then Return
MediaPlayer1.Position = Value / 100 * MediaPlayer1.Duration
If MediaPlayer1.IsPlaying = False Then 'in halat zamani etefagh miofte k music b akhar reside v karbar neshangaro b aval montaghel mikone
MediaPlayer1.Play
End If
timer1_Tick
End Sub
Sub Looping_CheckedChange(Checked As Boolean)
MediaPlayer1.Looping = Checked
End Sub
Sub imgstop_Click
MediaPlayer1.Stop
imgpause.Visible=False
imgplay.Visible=True
End Sub
Sub imgpause_Click
MediaPlayer1.Pause
imgpause.Visible=False
imgplay.Visible=True
End Sub
سوال
mohamad9204 19
سلام انشالله که خسته نباشید
آقا من میخوام چندتا صوت آفلاین رو فراخونی کنم دو تا مشکل دارم
1-وقتی با فرمت(mp3)کار میکنم فایل بخش میشه اما وقتی که با فرمت مورد نیازم(wma)کار میکنم خطای زیر رو میده
2-وقتی که وسط بخش بر رو stopمیزنم بعدش هم فایل رو دوباره play میکنم از اول شروع میشه
Sub Process_Globals Dim SQL As SQL Dim timer1 As Timer End Sub Sub Globals Dim cr As Cursor Dim i As Int:i=0 Private lblword As Label Private imgnex As ImageView Dim MediaPlayer1 As MediaPlayer Private btnsot As Button Dim barPosition As SeekBar Dim barVolume As SeekBar Dim lblPosition As Label Dim Looping As ToggleButton Private imgback As ImageView Private imgpause As ImageView Private imgplay As ImageView Private imgstop As ImageView End Sub Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("dors_soty") If File.Exists(File.DirInternal,"Textonee.db")=False Then File.Copy(File.DirAssets,"Textonee.db",File.DirInternal,"Textonee.db") End If SQL.Initialize(File.DirInternal,"Textonee.db",False) timer1.Initialize("timer1", 1000) Try cr=SQL.ExecQuery("SELECT*FROM sqldataa") cr.Position=i lblword.Text=cr.GetString("sot") Catch End Try MediaPlayer1.Initialize( ) MediaPlayer1.Load(File.DirAssets, lblword.Text) End Sub Sub imgnex_Click imgpause.Visible=False imgplay.Visible=True If MediaPlayer1.IsPlaying Then MediaPlayer1.stop End If i=i+1 Try cr=SQL.ExecQuery("SELECT*FROM sqldataa") cr.Position=i lblword.Text=cr.GetString("sot") Catch End Try End Sub Sub imgback_Click imgpause.Visible=False imgplay.Visible=True If MediaPlayer1.IsPlaying Then MediaPlayer1.stop End If i=i-1 Try cr=SQL.ExecQuery("SELECT*FROM sqldataa") cr.Position=i lblword.Text=cr.GetString("sot") Catch End Try End Sub Sub imgplay_Click MediaPlayer1.Initialize2("") MediaPlayer1.Load(File.DirAssets, lblword.Text) MediaPlayer1.play imgpause.Visible=True imgplay.Visible=False End Sub Sub Activity_Resume timer1.Enabled = True timer1_Tick End Sub Sub Activity_Pause (UserClosed As Boolean) If MediaPlayer1.IsPlaying Then MediaPlayer1.Pause timer1.Enabled = False End Sub Sub timer1_Tick If MediaPlayer1.IsPlaying Then barPosition.Value = MediaPlayer1.Position / MediaPlayer1.Duration * 100 lblPosition.Text = "Position: " & ConvertToTimeFormat(MediaPlayer1.Position) & _ " (" & ConvertToTimeFormat(MediaPlayer1.Duration) & ")" End If End Sub Sub ConvertToTimeFormat(ms As Int) As String Dim seconds, minutes As Int seconds = Round(ms / 1000) minutes = Floor(seconds / 60) seconds = seconds Mod 60 Return NumberFormat(minutes, 1, 0) & ":" & NumberFormat(seconds, 2, 0) 'ex: 3:05 End Sub Sub barVolume_ValueChanged (Value As Int, UserChanged As Boolean) MediaPlayer1.SetVolume(barVolume.Value / 100, barVolume.Value / 100) End Sub Sub barPosition_ValueChanged (Value As Int, UserChanged As Boolean) If UserChanged = False Then Return MediaPlayer1.Position = Value / 100 * MediaPlayer1.Duration If MediaPlayer1.IsPlaying = False Then 'in halat zamani etefagh miofte k music b akhar reside v karbar neshangaro b aval montaghel mikone MediaPlayer1.Play End If timer1_Tick End Sub Sub Looping_CheckedChange(Checked As Boolean) MediaPlayer1.Looping = Checked End Sub Sub imgstop_Click MediaPlayer1.Stop imgpause.Visible=False imgplay.Visible=True End Sub Sub imgpause_Click MediaPlayer1.Pause imgpause.Visible=False imgplay.Visible=True End Subلینک ارسال
به اشتراک گذاری در سایت های دیگر
6 پاسخ به این سوال تاکنون داده شده است
ارسالهای توصیه شده
بایگانی شده
این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.