Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Code To Count Number Of Video Views

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Code To Count Number Of Video Views

    What would the code look like to count the number of times a user clicks on a video to view it? Where would I place this code, in the video player in server events? Thanks for any help!

    #2
    Re: Code To Count Number Of Video Views

    Some details would be nice. Grid, UX, what video player, how are you invoking it. There are literally a billion ways to get stuff done in Alpha... including some reference or a sample component would help.

    If it's on a button, then you'd have a data-bound field which hold the video view count. When you click the button, get the current count, add 1 to it, and save that value back to the table.

    Comment


      #3
      Re: Code To Count Number Of Video Views

      It would be a button it a grid component. So you are saying to create a database field to hold the count in the table and then do what?

      Comment


        #4
        Re: Code To Count Number Of Video Views

        It really depends on what you want to do. You haven't said... but if it's a button in each row of the grid, then I'd assume you're playing a video that is distinct... per row. If your grid is editable, your table would have a video count column. Include that count field in the grid and hide it. When you click on the button, using .setValue() to update the count field and save the row, then play your video.

        Comment


          #5
          Re: Code To Count Number Of Video Views

          When someone clicks on an image in a grid component it plays a video. What I want after the image is clicked to play the video, I want to add 1 view to a count column in a database table. What I have so far is an action javascript that does an ajax callback to xbasic code that fires after the video player action javascript. The xbasic code I have so far is below, the error it is giving me is Invalid summary field type:

          define class Count
          dim userid as n


          userid = select id from (table_name) where id = :id
          UPDATE (table_name) set count = count + 1 where id = userid

          end class

          Sorry for confusion, does this help to explain it?

          Comment


            #6
            Re: Code To Count Number Of Video Views

            Is that everything in your XBasic? Where is :id coming from? Where are you executing the code to get userid. userid would have to be an argument for the Update statement.

            You have this in a class? Why?

            If this is everything, then stuff isn't right, and can be adjusted. If you've left out code, then post the full code.

            I understand your concept better now that you've explained it... and it's what I thought you wanted to do.

            Comment


              #7
              Re: Code To Count Number Of Video Views

              It is all the code I have right now, I know it isn't right. It should be pretty simple to do but not sure about the code. Any help would be appreciated!

              Comment


                #8
                Re: Code To Count Number Of Video Views

                I would first try a simpler route. You can certainly call XBasic code... but first... let's see if we can use the Grid for this.

                Is your Grid editable? And... can you add a field to the table your Grid is based on... something like "videoCount"?

                Comment


                  #9
                  Re: Code To Count Number Of Video Views

                  It is not editable but I have a count field that is selected in the grid. I can change the count field to editable.

                  Comment


                    #10
                    Re: Code To Count Number Of Video Views

                    Good... change the count field to editable. Now... on the image you click to run the video... how are you actually running the video? With Action Javascript? If so, then add another Action Javascript to the one you've already defined. It's action will be "Inline-Javascript".

                    Your "Inline-Javascript" code will be...

                    Code:
                    var rowNum = {Grid.RowNumber};
                    var currCnt = {grid.Object}.getValue('G','VIDEOCOUNT',rowNum);
                    currCnt = parseInt(currCnt);
                    currCnt = (isNaN(currCnt) ? 0 : currCnt);
                    currCnt += 1;
                    {grid.Object}.setValue('G','VIDEOCOUNT',rowNum,currCnt);
                    {grid.Object}.submitGridPartRow(rowNum);
                    Maybe move this Action Javascript to the top so that it will run first. Maybe it doesn't matter.

                    Here we get the current Row number we're on. Then we turn it into an Integer. If it's currently an empty field, we test for it being NaN.
                    If it is Nan we'll use 0, and if not we'll use the number we got. Add 1, then use .setValue, and then save the row.

                    Comment


                      #11
                      Re: Code To Count Number Of Video Views

                      It works however with it being editable, however the user can change the vote count which I don't want them to be able to do. If I change the count field to unedited then the count field doesn't update. Anyway I can change it so the user cant edit the vote count?

                      Comment


                        #12
                        Re: Code To Count Number Of Video Views

                        Sorry, I meant to add that you can use the "Hide column" property of your count field.

                        Comment


                          #13
                          Re: Code To Count Number Of Video Views

                          Sorry, I want the user to be able to see the number of video views. Isnt there some code that will update the field but not allow the user to change it but be able to see the number?

                          Comment


                            #14
                            Re: Code To Count Number Of Video Views

                            We'll get this yet...

                            Unhide the column, and in that column's "Enable expression" property put 1=0. Now, the column will be disabled from User's input, but not from our .setValue.

                            Comment


                              #15
                              Re: Code To Count Number Of Video Views

                              That works! Thanks for your help!

                              Comment

                              Working...
                              X