public static void PublishTest(Presentation pres)
        {
            Project proj     = pres.Project;
            Channel sourceCh = pres.ChannelsManager.GetChannelsByName("channel.audio")[0];
            Channel destCh   = pres.ChannelFactory.Create();

            destCh.Language = sourceCh.Language;
            destCh.Name     = String.Format("{0}.published", sourceCh.Name);

            Uri publishDestination = new Uri(pres.RootUri, "AudioPublishFlattenedDestination/");

            if (Directory.Exists(publishDestination.LocalPath))
            {
                foreach (string file in Directory.GetFiles(publishDestination.LocalPath))
                {
                    File.Delete(file);
                }
            }
            else
            {
                Directory.CreateDirectory(publishDestination.LocalPath);
            }
            TreeNodeTestDelegate del = new TreeNodeTestDelegate(
                delegate(TreeNode node)
            {
                if (node.Parent == node.Presentation.RootNode)
                {
                    return(true);
                }
                return(false);
            });
            PublishFlattenedManagedAudioVisitor publishVisitor = new PublishFlattenedManagedAudioVisitor(del, null);

            publishVisitor.SourceChannel        = sourceCh;
            publishVisitor.DestinationChannel   = destCh;
            publishVisitor.DestinationDirectory = publishDestination;
            pres.RootNode.AcceptDepthFirst(publishVisitor);

            publishVisitor.VerifyTree(pres.RootNode);

            Uri xukFile = new Uri(proj.Presentations.Get(0).RootUri, "TreeNodeTestsSample.xuk");

            if (File.Exists(xukFile.LocalPath))
            {
                File.Delete(xukFile.LocalPath);
            }
            proj.SaveXuk(xukFile);
            CheckPublishedFiles(pres.RootNode, sourceCh, destCh, null, null, null);
        }
예제 #2
0
        public void ExportToDaisy3(string exportDirectory)
        {
            //if (m_Presentation.RootNode.GetDurationOfManagedAudioMediaFlattened().TimeDeltaAsMillisecondLong == 0)
            //{
            //    System.Diagnostics.Debug.Fail("no audio found", "No audio node found in the project being exported");
            //}

            m_ID_Counter      = 0;
            m_OutputDirectory = exportDirectory;

            //TreeNodeTestDelegate triggerDelegate  = delegate(urakawa.core.TreeNode node) { return node.GetManagedAudioMedia () != null ; };
            TreeNodeTestDelegate triggerDelegate = doesTreeNodeTriggerNewSmil;
            TreeNodeTestDelegate skipDelegate    = delegate(urakawa.core.TreeNode node) { return(false); };

            PublishFlattenedManagedAudioVisitor publishVisitor = new PublishFlattenedManagedAudioVisitor(triggerDelegate, skipDelegate);

            if (!Directory.Exists(exportDirectory))
            {
                Directory.CreateDirectory(exportDirectory);
            }
            m_OutputDirectory = exportDirectory;

            publishVisitor.DestinationDirectory = new Uri(exportDirectory, UriKind.Absolute);

            publishVisitor.SourceChannel = m_Presentation.ChannelsManager.GetOrCreateAudioChannel();

            Channel publishChannel = m_Presentation.ChannelFactory.CreateAudioChannel();

            publishChannel.Name = PUBLISH_AUDIO_CHANNEL_NAME;
            publishVisitor.DestinationChannel = publishChannel;

            m_Presentation.RootNode.AcceptDepthFirst(publishVisitor);

            // The verification is not strictly necessary, but we should use it for testing all kinds of books, before stable release.
            publishVisitor.VerifyTree(m_Presentation.RootNode);

            // following functions can be called only in this order.
            CreateDTBookDocument();
            CreateNcxAndSmilDocuments();
            CreateOpfDocument();

            m_Presentation.ChannelsManager.RemoveManagedObject(publishChannel);
        }
예제 #3
0
        /// <summary>
        /// Creates audio files for export, it is important to call  function RemovePublishChannel after all export operations are complete
        /// </summary>
        /// <returns></returns>
        public Channel PublishAudioFiles()
        {
            m_adjustedExternalAudioFileNames.Clear();

            // if publish channel exists remove it.
            List <Channel> previousChannelsList = m_Presentation.ChannelsManager.GetChannelsByName(PUBLISH_AUDIO_CHANNEL_NAME);

            foreach (Channel previousChannel in previousChannelsList)
            {
                //m_Presentation.ChannelsManager.RemoveManagedObject(previousChannel);
                RemovePublishChannel(previousChannel);
            }

            ////TreeNodeTestDelegate triggerDelegate  = delegate(urakawa.core.TreeNode node) { return node.GetManagedAudioMedia () != null ; };
            //TreeNodeTestDelegate triggerDelegate = doesTreeNodeTriggerNewSmil;
            //TreeNodeTestDelegate skipDelegate = delegate { return false; };
            ConfigureAudioFileDelegates();

            m_PublishVisitor = new PublishFlattenedManagedAudioVisitor(m_TriggerDelegate, m_SkipDelegate);

            m_PublishVisitor.EncodePublishedAudioFiles = m_encodeAudioFiles;
            m_PublishVisitor.EncodingFileFormat        = EncodingFileFormat;

            if (m_encodeAudioFiles)
            {
                m_PublishVisitor.BitRate_Encoding = m_BitRate_Encoding;
                if (EncodingFileFormat == AudioFileFormats.MP3)
                {
                    m_PublishVisitor.SetAdditionalMp3EncodingParameters(m_AdditionalMp3ParamChannels, m_AdditionalMp3ParamReSample, m_AdditionalMp3ParamReplayGain);
                }
            }
            m_PublishVisitor.EncodePublishedAudioFilesSampleRate = m_sampleRate;
            m_PublishVisitor.EncodePublishedAudioFilesStereo     = m_audioStereo;
            m_PublishVisitor.DisableAcmCodecs = m_SkipACM;

            m_PublishVisitor.DestinationDirectory = new Uri(m_OutputDirectory, UriKind.Absolute);

            m_PublishVisitor.SourceChannel = m_Presentation.ChannelsManager.GetOrCreateAudioChannel();

            Channel publishChannel = m_Presentation.ChannelFactory.CreateAudioChannel();

            publishChannel.Name = PUBLISH_AUDIO_CHANNEL_NAME;
            m_PublishVisitor.DestinationChannel = publishChannel;

            //m_PublishVisitor.ProgressChangedEvent += new ProgressChangedEventHandler(ReportAudioPublishProgress);

            AddSubCancellable(m_PublishVisitor);
            m_Presentation.RootNode.AcceptDepthFirst(m_PublishVisitor);

#if DEBUG_TREE
            if (!m_PublishVisitor.EncodePublishedAudioFiles)
            {
                m_PublishVisitor.VerifyTree(m_Presentation.RootNode);
            }

            //Debugger.Break();
#endif //DEBUG
            RemoveSubCancellable(m_PublishVisitor);

            //m_PublishVisitor.ProgressChangedEvent -= new ProgressChangedEventHandler(ReportAudioPublishProgress);


            m_PublishVisitor = null;

            //if (EnableExplicitGarbageCollection)
            //{
            //    GC.Collect();
            //    GC.WaitForFullGCComplete();
            //}

            //if (RequestCancellation_RemovePublishChannel(publishChannel)) return;
            return(publishChannel);
        }