# Introducing CodePlayer - watch your code like a movie

DevFeed: [Introducing CodePlayer - watch your code like a movie](<https://devfeed.tech/articles/introducing-codeplayer-watch-your-code-like-a-movie-19987.md>)

Original publisher: [Read original article](<http://engineering.hackerearth.com/2014/01/21/introducing-codeplayer/>)

Published: 2014-01-21T00:00:00Z

Content type: release

Language: en

Sources: [HackerEarth](<https://devfeed.tech/sources/hackerearth.md>)

Topics: [Visual Studio Code](<https://devfeed.tech/topics/visual-studio-code.md>), [Database](<https://devfeed.tech/topics/database.md>), [autosave](<https://devfeed.tech/topics/autosave.md>)

Tags: [about](<https://devfeed.tech/tags/about.md>), [ajax](<https://devfeed.tech/tags/ajax.md>), [all](<https://devfeed.tech/tags/all.md>), [also](<https://devfeed.tech/tags/also.md>), [api](<https://devfeed.tech/tags/api.md>), [argument](<https://devfeed.tech/tags/argument.md>), [automatically](<https://devfeed.tech/tags/automatically.md>), [backend](<https://devfeed.tech/tags/backend.md>), [but](<https://devfeed.tech/tags/but.md>), [callback](<https://devfeed.tech/tags/callback.md>), [can](<https://devfeed.tech/tags/can.md>), [choice](<https://devfeed.tech/tags/choice.md>), [class](<https://devfeed.tech/tags/class.md>), [code](<https://devfeed.tech/tags/code.md>), [code-editors](<https://devfeed.tech/tags/code-editors.md>), [coding](<https://devfeed.tech/tags/coding.md>), [data](<https://devfeed.tech/tags/data.md>), [like](<https://devfeed.tech/tags/like.md>), [movie](<https://devfeed.tech/tags/movie.md>), [watch](<https://devfeed.tech/tags/watch.md>)

## AI overview

HackerEarth's CodePlayer records code editor changes and replays them as a video using Ace Editor's API. After editor load, it sets up video metadata through an AJAX request; keystrokes are queued locally and sent in batches after three seconds of inactivity, or immediately when the user leaves or closes the tab. Django bulk_create stores changesets, while separate coding sessions keep idle gaps from inflating playback length. During playback, timestamped changesets are applied at their corresponding video times; users can pause, seek, and adjust speed. The article says videos could be shared without login and describes the feature as integrated with HackerEarth and CodeTable editors. It also reports that autosave resulted from the implementation.

## Source excerpt

Ever thought of sharing solution of a coding problem in form of a video with someone, to teach them how you implemented the solution. Or, wanted to see what's the thought process of a potential employee when he/she solves a difficult problem. Ofcourse you have thought about it. But, it was not exactly possible to watch it as seamlessly as a movie until now. Today, we are announcing the release of HackerEarth's CodePlayer that exactly does that. tl;dr Watch a demo code video or Make your own code video. How it works CodePlayer is tightly integrated with all code editors in HackerEarth and sister site - CodeTable. That is, wherever you will find code editor in our site, there CodePlayer will also be activated. By choice, we have built it to be activated automatically in stealth mode on page load or first keystroke. Our code editor is built on top of Ace Editor. In ace editor, keystrokes or deltas can be captured and applied programmatically using Ace API. This is where the idea of playing code like a video seemed possible. CodePlayer was built on the following line of development: Setup Video Recording Keystrokes Playing Video Setup Video After the code editor is loaded, an AJAX POST request is made to server to setup video info in Django model. /** * This function sends ajax request to setup video. * This code is made generic to integrate it with code editor anywhere in site. * @arg video_obj: contains video info * @arg callback: called on success * @arg callback_arg_obj: above callback argument */ function setup_video(video_obj, callback, callback_arg_obj) { $.ajax({ url: '*****', type: 'POST', data: video_obj, dataType: 'json', callback: callback, callback_arg_obj: callback_arg_obj, success: function(response_obj) { this.callback(response_obj, this.callback_arg_obj); }, error: function(err) { } }); }; 
 Video model*(Backend)* class CodeVideo(Generic): final_code = models.TextField(null=True) # used as thumbnail lang = models.CharField(max_length=10) last_updated