Пример #1
0
        //create local asset from some external asset
        public IMediaAsset AddAsset(TypeOfMedia assetType, string assetPath)
        {
            string sTemp = null;

            if (assetType.Equals(TypeOfMedia.Audio))
            {
                sTemp = GenerateFileName(".wav", m_sDirPath);
            }


            if (sTemp != null)
            {
                try
                {
                    //File.Create (sTemp) ;
                    File.Copy(assetPath, sTemp, true);
                }
                catch
                {
                    MessageBox.Show("Exeption! file could not be created in add asset in asset manager");
                }

                AudioMediaAsset am = new AudioMediaAsset(sTemp);

                try
                {
                    m_htAssetList.Add(am.Name, am);
                }
                catch
                {
                    MessageBox.Show("Exeption! can not add duplicate in hash table");
                }
                return(am);
            }
            else
            {
                MessageBox.Show("Asset could not be created and added. A null exeption will be thrown");
                return(null);
            }
// end of function
        }
Пример #2
0
        //string type must contain valid extension like .wav
        // Parameter changed to enum TypeOfMedia
        public IMediaAsset NewAsset(TypeOfMedia assetType)
        {
            string sTemp = null;

            if (assetType.Equals(TypeOfMedia.Audio))
            {
                sTemp = GenerateFileName(".wav", m_sDirPath);
            }

            if (sTemp != null)
            {
                //File.Create (sTemp) ;
                BinaryWriter bw = new BinaryWriter(File.Create(sTemp));



                bw.BaseStream.Position = 0;
                byte b = Convert.ToByte(1);
                for (int i = 0; i < 44; i++)
                {
                    bw.Write(b);
                }
                b = Convert.ToByte(44);
                bw.BaseStream.Position = 7;
                bw.Write(b);
                bw.Close();

                AudioMediaAsset am = new AudioMediaAsset(sTemp);
                m_htAssetList.Add(am.Name, am);
                return(am);
            }
            else
            {
                MessageBox.Show("File could not be created and newAsset will throw a null exeption");
                return(null);
            }
        }