Video player!

This commit is contained in:
John 2015-07-08 15:30:25 +03:00
parent 43c45cc285
commit 6d1cf1ae43
4 changed files with 36 additions and 15 deletions

View file

@ -5,7 +5,8 @@ icon-filename phase_3/etc/icon.ico
cursor-filename phase_3/etc/toonmono.cur cursor-filename phase_3/etc/toonmono.cur
# Audio: # Audio:
audio-library-name p3fmod_audio audio-library-name p3openal_audio
video-library-name p3ffmpeg
# Graphics: # Graphics:
aux-display pandagl aux-display pandagl

View file

@ -1,6 +1,7 @@
from direct.interval.IntervalGlobal import *
import CatalogAtticItem import CatalogAtticItem
import CatalogItem import CatalogItem
import random import random, glob
from toontown.toonbase import TTLocalizer from toontown.toonbase import TTLocalizer
from toontown.toonbase import ToontownGlobals from toontown.toonbase import ToontownGlobals
from panda3d.core import * from panda3d.core import *
@ -1080,22 +1081,39 @@ class CatalogFurnitureItem(CatalogAtticItem.CatalogAtticItem):
if not scale == None: if not scale == None:
model.setScale(scale) model.setScale(scale)
model.flattenLight() model.flattenLight()
if self.furnitureType == 1530 and animate:
movie = loader.loadTexture('phase_5.5/movies/cheekyscrublords.avi')
self.sound = loader.loadSfx('phase_5.5/movies/cheekyscrublords.mp3')
movie.synchronizeTo(self.sound)
screen = NodePath(CardMaker('tv-screen').generate())
screen.reparentTo(model)
if self.furnitureType == 1530 and animate:
screen = NodePath(CardMaker('tv-screen').generate())
model.find('**/toonTownBugTV_screen').hide()
screen.reparentTo(model)
screen.setScale(2.5, 1.7, 1.4) screen.setScale(2.5, 1.7, 1.4)
screen.setPos(-1.15, -0.5, 1.1) screen.setPos(-1.15, -0.5, 1.1)
screen.setTexture(movie) self.startVideo(screen)
screen.setTexScale(TextureStage.getDefault(), movie.getTexScale())
model.find('**/toonTownBugTV_screen').hide()
self.sound.setLoop(True)
self.sound.play()
return model return model
def startVideo(self, model, file=None):
files = glob.glob('user/videos/*.mp4')
if not files:
model.setTextureOff(TextureStage.getDefault())
model.setColor(0.3, 0.3, 0.3, 1.0)
return
if file is None:
file = random.randint(0, len(files) - 1)
elif file >= len(files):
file = 0
movie = loader.loadTexture(files[file])
sound = loader.loadSfx(files[file])
movie.synchronizeTo(sound)
model.setTexture(movie)
model.setTexScale(TextureStage.getDefault(), movie.getTexScale())
self.videoSequence = Sequence(SoundInterval(sound, node=model, listenerNode=base.localAvatar), Func(self.startVideo, model, file + 1))
self.videoSequence.start()
def decodeDatagram(self, di, versionNumber, store): def decodeDatagram(self, di, versionNumber, store):
CatalogAtticItem.CatalogAtticItem.decodeDatagram(self, di, versionNumber, store) CatalogAtticItem.CatalogAtticItem.decodeDatagram(self, di, versionNumber, store)
self.furnitureType = di.getInt16() self.furnitureType = di.getInt16()

View file

@ -47,8 +47,8 @@ class DistributedFurnitureItem(DistributedHouseItem.DistributedHouseItem, Distri
def delete(self): def delete(self):
self.removeNode() self.removeNode()
if hasattr(self.item, 'sound'): if hasattr(self.item, 'videoSequence') and self.item.videoSequence:
self.item.sound.stop() self.item.videoSequence.pause()
del self.item del self.item
DistributedHouseItem.DistributedHouseItem.delete(self) DistributedHouseItem.DistributedHouseItem.delete(self)
DistributedSmoothNode.DistributedSmoothNode.delete(self) DistributedSmoothNode.DistributedSmoothNode.delete(self)

2
user/videos/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore