Results 1 to 8 of 8

Thread: Videos Watched total not incrementing

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2008
    Posts
    1,019

    Default

    I guess I'm a little lost here? That code updates the total number of videos that an individual user watches. So, when you go to your individual profile for that user, you can see how many videos that particular user has watched. The video's total views are recorded whether someone logs in or not. That is stored on the video itself (and not on the user). So, for each video, you have a total number of views. On a persons profile, you have a total number of videos that that particular person has watched.

    Question for you:

    Are you wanting to see a total for the number of times an individual's videos has been watched? For example, if I uploaded 50 videos and each video was watched 10 times, are you wanting to see something like "My videos have been watched 500 times"?
    vShare Solutions
    Custom vShare Modules and Services

    Now, your visitors can watch videos on your site using their mobile or tablet device with the Mobility Mod for vShare 2.8!

  2. #2
    Join Date
    Oct 2007
    Posts
    126

    Default

    Quote Originally Posted by bplex View Post
    I guess I'm a little lost here? That code updates the total number of videos that an individual user watches. So, when you go to your individual profile for that user, you can see how many videos that particular user has watched. The video's total views are recorded whether someone logs in or not. That is stored on the video itself (and not on the user). So, for each video, you have a total number of views. On a persons profile, you have a total number of videos that that particular person has watched.
    No, I am not sure you have me convinced.

    I went to one of my sites (oldskoolmedia.net), and viewed my profile which shows Videos Watched, Profile Views and my Watched videos (while logged in). Then I logged in as a different user and checked the numbers again. Only the profile viewed had increased. I then watched one of the videos owned by that user. Then clicked on the username to get back to the profile and the Videos Watched had increased.

    When I went to my own profile and checked the Videos Viewed number, then viewed one of my videos and then went back to check the number it had not incremented - meaning I could not increase my own number.

    You could try it for yourself on your site or on mine. (You would have to create an account to test on oldskoolmedia.net, but it would get deleted in a few days as it is a private site)

    So if the above description is indeed what is happening in v2.7, do I have something unique or is it something that has not been noticed by others?


    Quote Originally Posted by bplex View Post
    Question for you:

    Are you wanting to see a total for the number of times an individual's videos has been watched? For example, if I uploaded 50 videos and each video was watched 10 times, are you wanting to see something like "My videos have been watched 500 times"?
    Yep, that is it. Seems to work on one site (oldskoolmedia.net) but I have muddled it up on the other sites.

    I went to another of my sites (CasselmanCanada.com). It has free access with no login or viewer packages. My profile shows 70843 Videos Watched, but no matter how many videos I try to watch the number does not increase. I tried cleaning out my guest cache in the database but it does not affect the counter. I have no idea where the number came from, although the other two numbers in the profile are working correctly.
    CasselmanCanada.com (free access)


  3. #3
    Join Date
    Sep 2008
    Posts
    1,019

    Default

    Ok, so you are referring to the section of the page that says "Videos Watched X times" and not the "I've watched X videos" then. Interestingly, I looked at a vanilla demo site (vShare 2.7) that I have setup and it shows that my videos have been watched "0" times although I have looked at them before. This appears to be a bug. I'd have to look to see where it is as to fix it.
    vShare Solutions
    Custom vShare Modules and Services

    Now, your visitors can watch videos on your site using their mobile or tablet device with the Mobility Mod for vShare 2.8!

  4. #4
    Join Date
    Sep 2008
    Posts
    1,019

    Default

    Ok, after looking further into the code, this isn't a bug, per say, although it appears to function as one.

    The way that the code is written in vShare 2.7, a user must be logged in for any of those fields to be updated (Watched Videos or I've Watched, etc). Then, it only updates the videos if the user is not looking at their own videos (but someone elses). So, the behavior that you described is correct. If you want to change this behavior, you would need to replace lines 149-176 of the view_video.php code from:

    PHP Code:

    if (isset($_SESSION['UID']))
        {
            
    $sql "UPDATE `users` SET
                   `user_watched_video`=`user_watched_video`+1 WHERE
                   `user_id`='" 
    . (int) $_SESSION['UID'] . "'";
            
    mysql_query($sql) or mysql_die($sql);
            
            if (
    $_SESSION['UID'] != $video_info['video_user_id'])
            {
                
    $sql "UPDATE `users` SET
                       `user_video_viewed`=`user_video_viewed`+1 WHERE
                       `user_id`='" 
    . (int) $video_info['video_user_id'] . "'";
                
    mysql_query($sql) or mysql_die($sql);
            }
            
            
    $sql "SELECT * FROM `playlists` WHERE
                   `playlist_user_id`='" 
    . (int) $_SESSION['UID'] . "' AND
                   `playlist_video_id`='" 
    . (int) $video_id "'";
            
    $result mysql_query($sql) or mysql_die($sql);
            
            if (
    mysql_num_rows($result) == 0)
            {
                
    $sql "INSERT INTO `playlists` SET
                       `playlist_user_id`='" 
    . (int) $_SESSION['UID'] . "',
                       `playlist_video_id`='" 
    . (int) $video_id "'";
                
    $result mysql_query($sql) or mysql_die($sql);
            }
        } 
    To

    PHP Code:

    if (isset($_SESSION['UID']))
        {
            
    $sql "UPDATE `users` SET
                   `user_watched_video`=`user_watched_video`+1 WHERE
                   `user_id`='" 
    . (int) $_SESSION['UID'] . "'";
            
    mysql_query($sql) or mysql_die($sql);
            
             
            
    $sql "SELECT * FROM `playlists` WHERE
                   `playlist_user_id`='" 
    . (int) $_SESSION['UID'] . "' AND
                   `playlist_video_id`='" 
    . (int) $video_id "'";
            
    $result mysql_query($sql) or mysql_die($sql);
            
            if (
    mysql_num_rows($result) == 0)
            {
                
    $sql "INSERT INTO `playlists` SET
                       `playlist_user_id`='" 
    . (int) $_SESSION['UID'] . "',
                       `playlist_video_id`='" 
    . (int) $video_id "'";
                
    $result mysql_query($sql) or mysql_die($sql);
            }
        }
        
    $sql "UPDATE `users` SET
                `user_video_viewed`=`user_video_viewed`+1 WHERE
                `user_id`='" 
    . (int) $video_info['video_user_id'] . "'";
        
    mysql_query($sql) or mysql_die($sql); 
    vShare Solutions
    Custom vShare Modules and Services

    Now, your visitors can watch videos on your site using their mobile or tablet device with the Mobility Mod for vShare 2.8!

  5. #5
    Join Date
    Oct 2007
    Posts
    126

    Default

    That is the same conclusion I had come to when I started looking for answers. I had it down to the right section of code. Good thing a programmer like you knows how to move the lines around to make the stuff work properly.

    I changed the code on a couple of my sites and now the numbers are increasing properly.

    Thanks bplex.
    CasselmanCanada.com (free access)


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •