Hello,
Yes, Leadtools can play from a memory stream, and it should be possible to accomplish what you're looking to do. However, Leadtools does not provide any type of encryption methods in our SDK.
You'll want to set the SourceType to ltmmPlay_Source_HGlobal, and set the SourceHGlobal property on the player control to indicate where the memory is to play from.
Here is a code sample which will help illustrate how to play a file in memory:
Dim openFileDialog1 As New OpenFileDialog
Dim fn As String
Dim mmBinFileStream As System.IO.FileStream
'Present the user with a file open dialog box.
openFileDialog1.Filter = "BMP (*.bmp)|*.bmp|MPG (*.mpg)|*.mpg|Windows Media Audio (*.wma)|*.wma|Windows
Media Video (*.wmv)|*.wmv"
openFileDialog1.RestoreDirectory = True
If openFileDialog1.ShowDialog() = DialogResult.OK Then
fn = openFileDialog1.FileName
lblTitle.Text = "Title: " + fn.Substring(fn.LastIndexOf("\") + 1)
'***********************************************************
'For sourcefile method (works for any file format)
'ltmmPlayer.sourcefile = openFileDialog1.FileName
'***********************************************************
'For byte-array method (works for MPGs,WMAs,WMVs,AVIs, but not for BMPs!!!)
mmBinFileStream = New FileStream(fn, FileMode.Open)
ReDim mmBytes(mmBinFileStream.Length)
mmBinFileStream.Read(mmBytes, 0, mmBinFileStream.Length)
mmBinFileStream.Close()
mmPtr = Marshal.AllocHGlobal(mmBytes.Length())
Marshal.Copy(mmBytes, 0, mmPtr, mmBytes.Length())
ltmmPlayer.ResetSource()
ltmmPlayer.SourceHGlobal = mmPtr.ToInt32()
'ltmmPlayer.sourcefile = fn
'***********************************************************
End If
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.
![LEAD Logo LEAD Logo](https://www.leadtools.com/images/new-site-images/leadtools-logo-header.png)