Wednesday, October 26, 2011
-Added allowing users to click on the time line to change the current time of the media
-Add current time : duration text
-Make it look more presentable (round rectangles, better colors, etc.)
User creates a canvas and passes the plugin the canvas name along with wanted width, height, and the same media id as popcorn is passed.
The plugin then sets itself to be run at time zero, grabs a reference to the popcorn object calling it, sets up the canvas, and sets a listener on the media element.
When the media element is done loading, it stores a reference to the media element's video duration and current time.
An interval function is set with the draw function.
The draw function calls and stores the return value getTrackEvents using the stored popcorn instance that called the plugin, draws out the appropriate timeline box, draws the cursor in the right spot using the stored duration and currentTime variables, and then draws out the spots where events are going to be called by the popcorn instance.
Pretty simplistic so far but I'm going to add more features in the next few days such as:
When mouseover the canvas check the positioning of the mouse and check that versus the X coordinates of the showing events. Create a floating div over top showing some information like literal start time, literal end time, and a description if available.
Clicking on the timeline can change the currentTime of the media element so that you can use the visualized timeline bar as a normal timeline bar. Pause/Play could be implemented as well.
Going to clean it up and make it look a bit nicer playing with some of the canvas draw functions.
Could have the the current time drawn as text.
Research some better ways rather than drawing X frames per second.
*Below are just two screen shots showing the simplistic visualized timeline so far*
Tuesday, October 25, 2011
As discussed in my last post, I'm going to have to remove the current time cursor and add it back onto the base layer. Unless I use dynamic divs.
If I use styled divs I can set the current position cursor's div to the constantly changing current time of the media element. This would take a lot of the effort off my own code and change the div's relative position dynamically.
The steps in order to do so would be as followed:
1. Create an encapsulating div.
2. Create the wide base time line bar div.
3. Overlay the cursor div inheriting using the same Y position as the base and use it's X position as the current time variable within the media element. I can just use the duration variable in the media element to calculate the proper spot for the div in a calculation.
4. Lastly, just overlay the divs for the track event visuals with mouse over events at relative start time position for those events.
What I'll still need is:
Popcorn's media element's id to track it down on the page and get it's information.
A listener for the track events that will get their info.
The process order would be:
Create all the variables
Load all the variables on popcorn's media element
Create the event divs on addtrackevent call with mouseover event
This seems to be an a quicker and easier way to keep track of all the visuals needed to create the timeline.
Monday, October 24, 2011
I've come up with an idea of how it should work.
-Create variables to hold array of event tracks, and number of event tracks. Put number of event tracks into a safe state (0)
-When popcorn gets its media element, load the timeline data object with references to the media element (current and time), as well as a reference to the event tracks array and number of event tracks
-Draw a base for the visualized timeline that will have a current time cursor layer and event tracks layer on top
-When the current time changes, clear the layer containing the current time cursor, and add it back on at the appropriate spot.
(I'm a little worried this might be slow as every time the time changing, a removal and creation must happen)
-Whenever addTrackEvent is called, add that track into the track events array existing in the plugin, and add that track event onto the visualized timeline in the track event layer.
(This allows the plugin to keep track of track events that are created on the fly)
-A good idea would be to create a mouseover event to display a popup div with relevant data about a track event
Object for holding timeline data:
current: (current time in video - references video element's currentTime property)
time: (full video time - references video element's duration property)
tracks: (array holding event track objects - references a static array in the visualized timeline plugin)
nTracks: (number of tracks - references a static variables holdings number of even tracks in visualized timeline plugin)
So I have to figure out:
-How to get the media object upon popcorn instance creation
-How to have my plugin be notified upon track event creation/grab that track event to hold onto
The next few days should be interesting indeed.
Sunday, October 16, 2011
My teacher for Open Source made a good point about implementing this. It is extremely broad and a lot of things are to be taken into consideration.
Plugin vs. Direct Integration. Direct integration would be easier but how much would it bloat the core?
Canvas vs. Div. Plugins for now are all just using their own div, but using a canvas instead would be interesting. A canvas would allow for more graphical capabilities.
*OR* If possible edit the html5 video element's timeline directly.
Once I've further discussed this with other members of the popcorn team, there's one thing for now that may cause some problems. Popcorn is able to create a new event from a previous event. So when drawing out the visual timeline with all the events, some of them might not exist yet. However I end up doing the new timeline, it has to listen to event creations to re-update the timeline.
A trip to CDOT seems to be in store sometime tomorrow to talk with the popcorn team.