2012-03-23, 20:46
I'm doing something similar in 1Channel. I've been experimenting with different ways to do it, here's the simplest I've found so far: https://github.com/bstrdsmkr/1Channel/bl...layback.py
You can actually see some commented out code where I've messed with using different threads and etc. I used a property of the class object instead of writing to a file because some users were having issues with permissions and etc. As a bonus, it turned out to be noticeably more efficient, about a 3-5% cpu drop on my 3.0ghz dual core. (I think the file writes were getting queued and backing up).
Catching the onSeek() event should let you handle users trying to manually fast forward too far. Thinking about it more, I think you could probably do it by percentage and get close enough. getTotalTime() gives you the number of seconds for a given file size, so from that you can get a good idea of how many seconds you've downloaded. Then you could play with it and give yourself a little margin of error to make sure you don't seek too far.
You can actually see some commented out code where I've messed with using different threads and etc. I used a property of the class object instead of writing to a file because some users were having issues with permissions and etc. As a bonus, it turned out to be noticeably more efficient, about a 3-5% cpu drop on my 3.0ghz dual core. (I think the file writes were getting queued and backing up).
Catching the onSeek() event should let you handle users trying to manually fast forward too far. Thinking about it more, I think you could probably do it by percentage and get close enough. getTotalTime() gives you the number of seconds for a given file size, so from that you can get a good idea of how many seconds you've downloaded. Then you could play with it and give yourself a little margin of error to make sure you don't seek too far.