من یک نرم افزار دارم که میخوام وقتی کاربر به فرم مربوطه رفت یه دکمه دانولد گذاشتم با 2 تا ایمیج ویو که یکی برای پخش و یکی برای توقف هستش
برنامه در حالت عادی میره از مسیر مربوطه دانلود میکنه و با دکمه پلی هم پخش میشه مشکلی با این ندارم
ولی مشکلاتی که داره
1- میخوام وقتی کاربر برای اولین بار وارد برنامه میشه دکمه پلی و توقف غیر فعال باشه یا کلا محو باشه که بعد از دانلود که کامل شد نمایش داده شود
2- برای دفعات بعدی که کاربر وارد برنامه میشه چک کنه اگه فایل قبلا دانلود شده باشه دکمه های دانلود محو باشند یا کلا غیر فعال باشند
این سورس کد
#Region Activity Attributes
#FullScreen: true
#IncludeTitle: false
#End Region
Sub Process_Globals
Private link1 As String = "http://www.irmp3.ir/downloadp/s/eyJjdCI6Ikx5Wk1MSmxFaTJXbWQvZUw2UU9ad1E9PSIsIml2IjoiYjAxYTNjMWY4NGQ5NDVhZTEyNzE0OTgxMGEzZTMxMWUiLCJzIjoiODI2OWJhZTZlOTkxZDEwYiJ9.mp3"
Dim mediaplayer1 As MediaPlayer
Dim timer1 As Timer
End Sub
' www.Basic4Android.org
Sub Globals
Dim ProgressBar1 As ProgressBar
Dim Label1 As Label
Dim btnDownload As Button
Dim btnCancel As Button
Private lbltitle As Label
Private ProgressBar2 As ProgressBar
Private lblPosition As Label
Private barPosition As SeekBar
Private barVolume As SeekBar
Private Label3 As Label
Private Looping As ToggleButton
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
mediaplayer1.Initialize()
End If
Activity.LoadLayout("player")
lbltitle.Text = "گنجینه اول"
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 timer1_Tick
If mediaplayer1.IsPlaying Then
barPosition.Value = mediaplayer1.Position / mediaplayer1.Duration * 100
lblPosition.Text = "مدت زمان : " & ConvertToTimeFormat(mediaplayer1.Position) & _
" (" & ConvertToTimeFormat(mediaplayer1.Duration) & ")"
End If
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 'the value was changed programmatically
' mediaplayer1.Position = Value / 100 * mediaplayer1.Duration
' If mediaplayer1.IsPlaying = False Then 'this can happen when the playback reached the end and the user changes the position
' mediaplayer1.Play
' End If
' timer1_Tick 'immediately update the progress label
'End Sub
Sub btnDownload_Click
Dim dd As DownloadData
dd.url = link1
dd.EventName = "dd"
dd.Target = Me
CallSubDelayed2(DownloadService, "StartDownload", dd)
End Sub
Sub dd_Progress(Progress As Long, Total As Long)
ProgressBar1.Progress = Progress / Total * 100
Label1.Text = NumberFormat(Progress / 1024, 0, 0) & "KB / " & _
NumberFormat(Total / 1024, 0, 0) & "KB"
End Sub
Sub dd_Complete(Job As HttpJob)
Log("Job completed: " & Job.Success)
Job.Release
End Sub
Sub btnCancel_Click
CallSubDelayed2(DownloadService, "CancelDownload", link1)
End Sub
Sub play_Click
mediaplayer1.Load(File.DirInternal,"Mehrdad_Asemani-Konje_Mahtab-(WWW.IRMP3.IR).mp3")
timer1.Initialize("timer1",1000)
mediaplayer1.Play
timer1.Enabled = True
timer1_Tick
End Sub
Sub pause_Click
If mediaplayer1.IsPlaying Then mediaplayer1.Pause
timer1.Enabled = False
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If mediaplayer1.IsPlaying Then mediaplayer1.Pause
timer1.Enabled = False
End Sub
سوال
faxmodem 2
با سلام
من یک نرم افزار دارم که میخوام وقتی کاربر به فرم مربوطه رفت یه دکمه دانولد گذاشتم با 2 تا ایمیج ویو که یکی برای پخش و یکی برای توقف هستش
برنامه در حالت عادی میره از مسیر مربوطه دانلود میکنه و با دکمه پلی هم پخش میشه مشکلی با این ندارم
ولی مشکلاتی که داره
1- میخوام وقتی کاربر برای اولین بار وارد برنامه میشه دکمه پلی و توقف غیر فعال باشه یا کلا محو باشه که بعد از دانلود که کامل شد نمایش داده شود
2- برای دفعات بعدی که کاربر وارد برنامه میشه چک کنه اگه فایل قبلا دانلود شده باشه دکمه های دانلود محو باشند یا کلا غیر فعال باشند
این سورس کد
#Region Activity Attributes #FullScreen: true #IncludeTitle: false #End Region Sub Process_Globals Private link1 As String = "http://www.irmp3.ir/downloadp/s/eyJjdCI6Ikx5Wk1MSmxFaTJXbWQvZUw2UU9ad1E9PSIsIml2IjoiYjAxYTNjMWY4NGQ5NDVhZTEyNzE0OTgxMGEzZTMxMWUiLCJzIjoiODI2OWJhZTZlOTkxZDEwYiJ9.mp3" Dim mediaplayer1 As MediaPlayer Dim timer1 As Timer End Sub ' www.Basic4Android.org Sub Globals Dim ProgressBar1 As ProgressBar Dim Label1 As Label Dim btnDownload As Button Dim btnCancel As Button Private lbltitle As Label Private ProgressBar2 As ProgressBar Private lblPosition As Label Private barPosition As SeekBar Private barVolume As SeekBar Private Label3 As Label Private Looping As ToggleButton End Sub Sub Activity_Create(FirstTime As Boolean) If FirstTime Then mediaplayer1.Initialize() End If Activity.LoadLayout("player") lbltitle.Text = "گنجینه اول" 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 timer1_Tick If mediaplayer1.IsPlaying Then barPosition.Value = mediaplayer1.Position / mediaplayer1.Duration * 100 lblPosition.Text = "مدت زمان : " & ConvertToTimeFormat(mediaplayer1.Position) & _ " (" & ConvertToTimeFormat(mediaplayer1.Duration) & ")" End If 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 'the value was changed programmatically ' mediaplayer1.Position = Value / 100 * mediaplayer1.Duration ' If mediaplayer1.IsPlaying = False Then 'this can happen when the playback reached the end and the user changes the position ' mediaplayer1.Play ' End If ' timer1_Tick 'immediately update the progress label 'End Sub Sub btnDownload_Click Dim dd As DownloadData dd.url = link1 dd.EventName = "dd" dd.Target = Me CallSubDelayed2(DownloadService, "StartDownload", dd) End Sub Sub dd_Progress(Progress As Long, Total As Long) ProgressBar1.Progress = Progress / Total * 100 Label1.Text = NumberFormat(Progress / 1024, 0, 0) & "KB / " & _ NumberFormat(Total / 1024, 0, 0) & "KB" End Sub Sub dd_Complete(Job As HttpJob) Log("Job completed: " & Job.Success) Job.Release End Sub Sub btnCancel_Click CallSubDelayed2(DownloadService, "CancelDownload", link1) End Sub Sub play_Click mediaplayer1.Load(File.DirInternal,"Mehrdad_Asemani-Konje_Mahtab-(WWW.IRMP3.IR).mp3") timer1.Initialize("timer1",1000) mediaplayer1.Play timer1.Enabled = True timer1_Tick End Sub Sub pause_Click If mediaplayer1.IsPlaying Then mediaplayer1.Pause timer1.Enabled = False End Sub Sub Activity_Resume End Sub Sub Activity_Pause (UserClosed As Boolean) If mediaplayer1.IsPlaying Then mediaplayer1.Pause timer1.Enabled = False End Subلینک ارسال
به اشتراک گذاری در سایت های دیگر
10 پاسخ به این سوال تاکنون داده شده است
ارسالهای توصیه شده
بایگانی شده
این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.