Prev: vbScript Editor with Intellisense
Next: tutorials
From: Ducati on 2 Feb 2010 14:56 I am trying to validate a streaming URL in the form of mms://..../file.wmv, by using the WMPlayer controls. So far I found a way to play the URL and by interpreting the status message find out if the file is playing or not and therefore validates its existence (see Script below). My problem is that I must give it at least a second to try and Play the URL to get a valid result. When having to test a large number of links, it makes the process quite slow. I was wondering if there are other method/controls I could use with WMPlayer.OCX.7 to simply check some file attribute (Like size or duration...) which could be faster than playing the file. Thanks for any suggestions Current working script: Set Shell = CreateObject( "WScript.Shell" ) dim strURL, objWMP strURL = "mms://......file.wmv" Set objWMP = CreateObject("WMPlayer.OCX.7") objWMP.url = strURL ' starts playing the URL if it exists WScript.Sleep(1000) if left (objWMP.status, 4) = "Play" then Msgbox "Valid URL" else MsgBox "Invalid URL" end if objWMP.close set objWMP = nothing WScript.Quit
From: Reventlov on 3 Feb 2010 17:35 Il giorno Tue, 2 Feb 2010 11:56:06 -0800, =?Utf-8?B?RHVjYXRp?= <Ducati(a)discussions.microsoft.com> ha scritto: >I was wondering if there are other method/controls I could use with >WMPlayer.OCX.7 to simply check some file attribute (Like size or duration...) >which could be faster than playing the file. '************************************************ ' File: Lista file Mp3.vbs ' Autore: Giovanni Cenati ' http://digilander.libero.it/Cenati ' Codice liberamente utilizzabile citando il sito. ' Crea in excel una lista dei files Mp3 con alcuni dati aggiuntivi. ' Creates an excel file with a list of Mp3 files and some additional data. ' 2004/11/02 '************************************************ Set Player = createobject("wmplayer.ocx.7") Set fso = CreateObject("Scripting.FileSystemObject") set oXL = WScript.CreateObject("Excel.Application") oXL.Visible = TRUE oXL.WorkBooks.Add 'drive= inputbox ("Scan which drive?","List of Mp3 files - Cenati Giovanni","C:\") drive= inputbox ("Nome del drive in cui cercare:","Lista files Mp3 - Cenati Giovanni","C:\") Mp3List= GetListOfMp3Files(drive) songslist = Split(Mp3List, vbCrLf) 'Creates an array of the lines of the file Mp3List="" dim attr(10) attr(1)= "Artist" attr(2)= "Album" attr(3)= "Author" attr(4)= "Bitrate" attr(5)= "CreationDate" attr(6)= "Genre" ' Column Headers - Intestazioni delle colonne oXL.cells(1,1)="File Name" oXL.cells(1,2)="Name" oXL.cells(1,3)="Durata(secondi)" oXL.cells(1,4)="Durata(min,sec)" for i= 1 to ubound(attr) oXL.cells(1,4+i)=attr(i) next oXL.cells(1,11)="File size" oXL.cells(1,12)="File date" on error resume next 'for song names with accents ����� for songnumber=0 to ubound(songslist) row=songnumber+2 player.mediaCollection.add(songslist(songnumber)) player.url=songslist(songnumber) oXL.cells(row,1)= songslist(songnumber) oXL.cells(row,2)= player.currentmedia.name oXL.cells(row,3)= player.currentmedia.duration oXL.cells(row,4)= player.currentmedia.durationstring for a=1 to 6 oXL.cells(row,4+a)= player.currentMedia.getItemInfobyAtom(player.mediaCollection.getMediaAtom(attr(a))) next set f = fso.GetFile(songslist(songnumber)) oXL.cells(row,11)= f.size oXL.cells(row,12)= f.DateCreated wscript.sleep 60 'Altrimenti si blocca - Otherwise it hangs next oxl.cells(1,1).select set oXl=nothing msgbox "End of job - Cenati Giovanni" ,,"List of Mp3 Files" function GetListOfMp3Files(drive) dim fso, tmp, wshshell, ofile, path cmd = "dir "& trim(drive) & "*.mp3 /s/b " ' Comando DOS Const tmpFolder=2 Set fso = CreateObject("Scripting.FileSystemObject") ' Chiede al sistema un nome di file temporaneo. ' Asks Windows a unique temporary file name tmp = fso.GetTempName ' Recupera il path del file temporaneo. ' Gets the complete path of the temp file path = fso.GetSpecialFolder(tmpFolder) tmp = path & "\" & tmp ' Questo � il pathname completo del file tmp. ' Crea un oggetto WshShell... Creates the needed wshell object Set WshShell = CreateObject("WScript.Shell") ' Esegue il comando dos e redirige l'output sul file tmp ' Executes dos command and redirects the output on the tmp file WSHShell.Run "%comspec% /c " & cmd & " >" & tmp, 0, True ' Legge il contenuto del file. Reads the content Set oFile = fso.OpenTextFile(tmp) GetListOfMp3Files = oFile.ReadAll oFile.Close 'lo chiude - Closes the file fso.DeleteFile tmp ' e lo cancella - and deletes it end function ' *** End *** -- Giovanni Cenati (Bergamo, Italy) Write to "Reventlov" at katamail com http://digilander.libero.it/Cenati (Esempi e programmi in VbScript) --
From: Reventlov on 15 Feb 2010 17:18 Il giorno Fri, 12 Feb 2010 15:12:01 -0800, =?Utf-8?B?RHVjYXRp?= <Ducati(a)discussions.microsoft.com> ha scritto: >It not only loads the file, but it actually starts playing it in the >background (at least the Audio). >When I run my script on a good url, as soon as it gets to objWMP.url = >strURL , I start hearing the Audio of the Video stream (but no Video >display), and it plays until I do an objWMP.close. > >Do you know where I can get hold of the wmpsdk.chm file ? I found it in a cd together with a book about wmp deployment, but it should be somewhere in ms site. It's 1mb. I can send it to you. Write me at the address below @katamail.com -- Giovanni Cenati (Bergamo, Italy) Write to "Reventlov" at katamail com http://digilander.libero.it/Cenati (Esempi e programmi in VbScript) --
From: Ducati on 16 Feb 2010 14:35 Thanks, I did find it online. I was able to make a script that gathers thing like duration, but unfortunately, it only works when the file is local, when using an online mms:... video file, it does not work (always returns zero). Obviously the best solution is what I have working for now, and it is to attempt to play the file, and check if it is succeding thanks again for all the help "Reventlov" wrote: > Il giorno Fri, 12 Feb 2010 15:12:01 -0800, =?Utf-8?B?RHVjYXRp?= > <Ducati(a)discussions.microsoft.com> ha scritto: > > >It not only loads the file, but it actually starts playing it in the > >background (at least the Audio). > >When I run my script on a good url, as soon as it gets to objWMP.url = > >strURL , I start hearing the Audio of the Video stream (but no Video > >display), and it plays until I do an objWMP.close. > > > >Do you know where I can get hold of the wmpsdk.chm file ? > > I found it in a cd together with a book about wmp deployment, but it should be somewhere > in ms site. > It's 1mb. I can send it to you. Write me at the address below @katamail.com > > -- > Giovanni Cenati (Bergamo, Italy) > Write to "Reventlov" at katamail com > http://digilander.libero.it/Cenati (Esempi e programmi in VbScript) > -- > . >
From: Reventlov on 17 Feb 2010 16:44
Il giorno Fri, 12 Feb 2010 15:12:01 -0800, =?Utf-8?B?RHVjYXRp?= <Ducati(a)discussions.microsoft.com> ha scritto: >It not only loads the file, but it actually starts playing it in the >background (at least the Audio). >When I run my script on a good url, as soon as it gets to objWMP.url = >strURL , I start hearing the Audio of the Video stream (but no Video >display), and it plays until I do an objWMP.close. Settings.autoStart The autoStart property specifies or retrieves a value indicating whether the current media item begins playing automatically. Syntax player.settings.autoStart Possible Values This property is a read/write Boolean. true Default. The media item begins playing automatically. false The media item does not begin playing automatically. Remarks If autoStart is set to true, the media clip will begin playing as soon as Player.URL or Player.currentMedia is set. Otherwise, it will not start playing until the player.controls.play method is called. Because the autoStart property can be set globally by external events (such as loading a CD), you should set autoStart to false immediately before you set Player.URL or Player.currentMedia if you wish to ensure that the media item does not start playing immediately. -- Giovanni Cenati (Bergamo, Italy) Write to "Reventlov" at katamail com http://digilander.libero.it/Cenati (Esempi e programmi in VbScript) -- |