INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: How to Play a file?  (Read 1573 times)

Tanoshimi

  • Junior Woodchuck
  • **
  • Posts: 57
How to Play a file?
« on: August 12, 2006, 03:21:31 pm »

My plugin allows you to select a file and play it.  In order to do that, I clear the PlayingNow list, add the selected file to it, then use the Playback.Play command.  What happens is I get "There is nothing to play" but when I check the PlayingNow, the selected file is in there.  Apparently, there is no default within PlayingNow, and the file within that list must be selected first, but I see no way of doing that.  Can someone help me with code that will play a selected file?  Here's what I have so far...
       Set aFile = mFiles.GetFile(i)
       Set aPlayback = g_MJ.GetPlayback
       Set aPlayNow = g_MJ.GetCurPlaylist
       aPlayNow.RemoveAllFiles
       aPlayNow.AddFile aFile.Filename, 0
       aPlayback.Play
As I said, this puts the correct file in PlayingNow, but generates a "There is nothing to play" error.  I've tried it using the AddFromKey command too.  There's no problem with getting it into the PlayingNow, only with playing it.
Thanks,
-Tano
Logged

KingSparta

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 20048
Re: How to Play a file?
« Reply #1 on: August 14, 2006, 01:23:16 pm »

this works for MC12, should work in MC11 by changing the object names to the ref in the "Media Center.tlb" file. MC12 uses a new tlb filename "Media Center 12.tlb"

Code: [Select]
Private Sub PlayMyFile()
    ' Trap Errors
    On Error Resume Next
    '
    ' get the current playlist object
    Dim MCCurPlaylist As MediaCenter.IMJCurPlaylistAutomation
    Set MCCurPlaylist = g_MC.GetCurPlaylist
    '
    ' Remove Files In Playing Now
    MCCurPlaylist.RemoveAllFiles
    '
    ' get all the files in the library
    Dim MCFiles As MediaCenter.IMJFilesAutomation
    Set MCFiles = g_MC.Search("")
    '
    ' get a file in this case file # 0
    Dim MCFile As MediaCenter.IMJFileAutomation
    Set MCFile = MCFiles.GetFile(0) '
    '
    ' Add A File at pos
    MCCurPlaylist.AddFile MCFile.FileName, 0
    '
    ' set the first file to play 0 = beginning of play list
    MCCurPlaylist.Position = 0
    '
    ' Start Playback
    Dim aPlayback As MediaCenter.IMJPlaybackAutomation
    Set aPlayback = g_MC.GetPlayback
    '
    aPlayback.Play
    '
End Sub
Logged
Retired Military, Airborne, Air Assault, And Flight Wings.
Model Trains, Internet, Ham Radio
https://MyAAGrapevines.com
Fayetteville, NC, USA

Tanoshimi

  • Junior Woodchuck
  • **
  • Posts: 57
Re: How to Play a file?
« Reply #2 on: August 14, 2006, 01:44:50 pm »

Thanks for the help!  Mad Kudos to you.  I had everything right except the Position wasn't set.  That's what I needed, and it works like a charm.
-Tano
Logged
Pages: [1]   Go Up