Пример #1
0
        public static CrunchResponse AudioPlayerPlay(PlayBehavior playBehavior, string url, string token, string expectedPreviousToken, int offsetInMilliseconds)
        {
            var response = BuildResponse(null, true, null, null, null);

            response.Response.Directives.Add(new AudioPlayerPlayDirective()
            {
                PlayBehavior = playBehavior,
                AudioItem    = new AudioItem()
                {
                    Stream = new AudioItemStream()
                    {
                        Url   = url,
                        Token = token,
                        ExpectedPreviousToken = expectedPreviousToken,
                        OffsetInMilliseconds  = offsetInMilliseconds
                    }
                }
            });

            return(response);
        }
Пример #2
0
 public void AddAudioPlayer(PlayBehavior behavior, string url, string enqueuedToken, string token, int offset)
 {
     RemoveDirective();
     Skill = ResponseBuilder.AudioPlayerPlay(behavior, url, enqueuedToken, token, offset);
     Skill.Response.ShouldEndSession = true;
 }
Пример #3
0
 public void AddAudioPlayer(PlayBehavior behavior, string url, string token)
 {
     RemoveDirective();
     Skill = ResponseBuilder.AudioPlayerPlay(behavior, url, token);
     Skill.Response.ShouldEndSession = true;
 }
Пример #4
0
 public static CrunchResponse AudioPlayerPlay(PlayBehavior playBehavior, string url, string token, int offsetInMilliseconds)
 {
     return(AudioPlayerPlay(playBehavior, url, token, null, offsetInMilliseconds));
 }
Пример #5
0
 public static CrunchResponse AudioPlayerPlay(PlayBehavior playBehavior, string url, string token)
 {
     return(AudioPlayerPlay(playBehavior, url, token, 0));
 }
        public void PlayEvent(int event_id, PhotoshopTypeLibrary.IActionDescriptor parameter_desc, int show_ui, PlayBehavior action)
        {
            /*event_id - the event to play
             * parameter_descriptor - a descriptor containing the parameters for the event
             * dialog_options - whether to show UI or not
             * action - the kind of error checking to use. Possilble values are checkresult,checknonresult, and checknone
             *
             *
             * checkresult and checknonresult will cause
             * ExtensionError exceptions to be thrown if Photoshop
             * says there is an error. Regardless of the value used
             * for action, a number of ExtensionError exceptions may
             * be thrown.
             *
             */

            string event_id_str = GetNameFromEventID(event_id);

            //self.log.Header( "Play %s (0x%d) " % (event_id_str, event_id ) )


            PhotoshopTypeLibrary.IActionDescriptor result_desc = m_control.Play(event_id, parameter_desc, show_ui);

            // phKeyMessage may be present and contain more information about the event
            // store the value in msg
            string msg = null;


            if (result_desc != null)
            {
                object msg_o = get_value_from_descriptor(result_desc, (int)PSConstants.phKeyMessage);
                msg = (string)msg_o;;

                dump_descriptor(result_desc, 0);
            }

            bool success = false;

            // Depending on the action there are different criterias for success
            if (action == PlayBehavior.checkresult)
            {
                // Succes is one of the following:
                // - Play() did not return a descriptor
                // - Play() did return a descriptor and that did not contain phKeyMessage
                success = ((result_desc == null) || ((result_desc != null) && (msg == null)));
            }
            else if (action == PlayBehavior.checknonresult)
            {
                // Success is:
                // - Play() did return a descriptor and there is a message
                success = ((result_desc != null) && (msg != null));
            }
            else
            {
                // action == self.checknone ) :
                // Whatever happened is success
                // checknone is for temporary code, callers should end up using checkresult or checknonresult
                success = true;
            }

            if (!success)
            {
                string error_msg = "Photoshop ExtensionError: Failure on Event " + event_id_str;
                if (msg != null)
                {
                    error_msg += msg;
                    var e = new PhotoshoProxyError(error_msg);
                    throw (e);
                }
            }

            //self.log.Header( "PLAY" )
            //self.DumpDescriptor( result_desc, 0)
        }