بچه ها یه به این کدا یه نگاه بندازید ببنید کجا مشکل داره که بعضی لینک های فیلما نشون نمیده ارور عدم پخش میده میخوام هرلینک فیلمی که دادم پخش کنه .
Sub Class_Globals
Private ht As HttpJob
Private sFileName As String
Private VideoView1 As VideoView
Private Url As String
Dim dier As String
End Sub
#Region Initialize Video Stream
'Play Video if it is cache and if not cache then download it
'and show in videoView
Public Sub Initialize(sUrl As String,VideoViews As VideoView)
dier = File.DirRootExternal& "/ehsan"
sFileName = sUrl.SubString(sUrl.LastIndexOf("/")+1)
VideoView1 = VideoViews
'If File.Exists(File.DirRootExternal,sFileName) = False Then
If File.Exists(dier,sFileName) = False Then
If checkInternet = False Then
ToastMessageShow("فایل موجود نمی باشد",True)
ToastMessageShow("لطفا اینترنت را فعال کنید",True)
Return
End If
Url = sUrl
initHttp
Httputils.Download("downloadFile",sUrl)
Else
'VideoViews.LoadVideo(File.DirRootExternal,sFileName)
VideoViews.LoadVideo(dier,sFileName)
VideoViews.Play
End If
End Sub
Sub initHttp
Httputils.CallbackActivity = "actDownload"
Httputils.CallbackJobDoneSub = "JobDone"
Httputils.CallbackUrlDoneSub = "UrlDone"
Httputils.CallbackProgressSub="ProgressHTTP"
End Sub
#End Region
Private Sub JobDone (Job As String)
dier = File.DirRootExternal& "/ehsan"
Select Job
Case "downloadFile"
If Httputils.IsSuccess(Url) Then
'HttpUtils.SaveFile(Url,File.DirRootExternal,sFileName)
Httputils.SaveFile(Url,dier,sFileName)
'VideoView1.LoadVideo(File.DirRootExternal,sFileName)
VideoView1.LoadVideo(dier,sFileName)
VideoView1.Play
End If
End Select
Httputils.Complete = False
End Sub
Sub checkInternet As Boolean
Dim p As Phone
Dim connected As Boolean
connected = False
If (p.GetDataState == "CONNECTED") Then
connected = True
End If
If (p.GetSettings ("wifi_on") == 1) Then
connected = True
End If
Return connected
End Sub
'Version 1.04
Sub Process_Globals
Dim Tasks As List 'List of URLs to fetch.
'A map that holds the successful links.
'The links are stored as keys. The values are not used.
Dim SuccessfulUrls As Map
Dim Working As Boolean 'True when a job is still running
Dim Complete As Boolean 'True after a job has completer
Dim Job As String 'Name of the current running Job
Dim CallbackActivity As String 'Name of Activity that handles the callbacks.
Dim CallbackJobDoneSub As String 'Name of the JobDone callback sub.
Dim CallbackUrlDoneSub As String 'Name of the UrlDone callback sub.
Dim CallbackProgressSub As String 'download progress of file
Type ProgressStatus(Downloaded As Long,Total As Long)
End Sub
'Download a single resource (GET method).
Sub Download(JobName As String, URL As String)
DownloadList(JobName, Array As String(URL))
End Sub
'Downloads a list of resources (GET method).
Sub DownloadList(JobName As String, URLs As List)
If internalCheckIfCanStart(JobName) = False Then Return
Tasks = URLs
HttputilsService.Post = False
StartService(HttputilsService)
End Sub
'Sends a POST request with the given string as the post data
Sub PostString(JobName As String, URL As String, Text As String)
PostBytes(JobName, URL, Text.GetBytes("UTF8"))
End Sub
'Sends a POST request with the given file send as the post data.
Sub PostFile(JobName As String, URL As String, Dir As String, FileName As String)
If internalCheckIfCanStart(JobName) = False Then Return
Dim length As Int
If Dir = File.DirAssets Then
Log("Cannot send files from the assets folder.")
Return
End If
length = File.Size(Dir, FileName)
Dim In As InputStream
In = File.OpenInput(Dir, FileName)
If length < 1000000 Then '1mb
'There are advantages for sending the file as bytes array. It allows the Http library to resend the data
'if it failed in the first time.
Dim out As OutputStream
out.InitializeToBytesArray(length)
File.Copy2(In, out)
HttputilsService.PostInputStream = Null
HttputilsService.PostBytes = out.ToBytesArray
Else
HttputilsService.PostInputStream = In
HttputilsService.PostLength = length
End If
Tasks = Array As String(URL)
HttputilsService.Post = True
StartService(HttputilsService)
End Sub
'Sends a POST request with the given data as the post data.
Sub PostBytes(JobName As String, URL As String, Data() As Byte)
If internalCheckIfCanStart(JobName) = False Then Return
HttputilsService.PostInputStream = Null
HttputilsService.PostBytes = Data
Tasks = Array As String(URL)
HttputilsService.Post = True
StartService(HttputilsService)
End Sub
Sub internalCheckIfCanStart(JobName As String) As Boolean
If Working Then
Log("Already working. Request ignored (" & JobName & ")")
Return False
End If
Log("Starting Job: " & JobName)
Job = JobName
Working = True
Complete = False
SuccessfulUrls.Initialize
Return True
End Sub
Sub IsSuccess(URL As String) As Boolean
Return SuccessfulUrls.ContainsKey(URL)
End Sub
'Get methods should be called only after the JobDone event or the UrlDone event.
Sub GetString(URL As String) As String
If IsSuccess(URL) = False Then
Log("Task not completed successfully.")
Return ""
End If
Return File.GetText(HttputilsService.TempFolder, SuccessfulUrls.Get(URL))
End Sub
Sub GetBitmap(URL As String) As Bitmap
Dim b As Bitmap
If IsSuccess(URL) = False Then
Log("Task not completed successfully.")
Return b
End If
b = LoadBitmap(HttputilsService.TempFolder, SuccessfulUrls.Get(URL))
Return b
End Sub
Sub SaveFile(URL As String, LocalPath As String,Fname As String)
If IsSuccess(URL) = False Then
Log("Task not completed successfully.")
End If
File.Copy(HttputilsService.TempFolder, SuccessfulUrls.Get(URL),LocalPath,Fname)
End Sub
Sub GetInputStream(URL As String) As InputStream
Dim In As InputStream
If IsSuccess(URL) = False Then
Log("Task not completed successfully.")
Return In
End If
In = File.OpenInput(HttputilsService.TempFolder, SuccessfulUrls.Get(URL))
Return In
End Sub
سوال
naser sahami 90
بچه ها یه به این کدا یه نگاه بندازید ببنید کجا مشکل داره که بعضی لینک های فیلما نشون نمیده ارور عدم پخش میده میخوام هرلینک فیلمی که دادم پخش کنه .
لینک ارسال
به اشتراک گذاری در سایت های دیگر
4 پاسخ به این سوال تاکنون داده شده است
ارسالهای توصیه شده
بایگانی شده
این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.