Video texture with sound?

Hi everyone, i want to ask if this script could be modified like this (or somehow else). I found this script from http://www.tutorialsforblender3d.com . It let a texture displays a video in your scene but doesnt let it give the sound of that. I separate the video and sound part of that video file and let them load to the game with this… but it doesnt seem to work.

Only when i comment at these lines:

soundName = obj['sound']
sound = aud.Factory.file((bge.logic.expandPath('//sounds/' + soundName))

Thank you in advance

#######################################################
# Movie.py Blender 2.6
#
# Tutorial for using Video.py can be found at
#
# www.tutorialsforblender3d.com
#
# Released under the Creative Commons Attribution 3.0 Unported License. 
#
# If you use this code, please include this information header.
#
######################################################


#import bge
import bge
import aud
 


# get the current controller
controller = bge.logic.getCurrentController()


# get object script is attached to
obj = controller.owner


# check to see variable Video has been created
if "Video" in obj:
    
    # get video 
    video = obj["Video"]
    
    # update the video 
    video.refresh(True)








# if variable Video hasn't been created
else:


    # get current scene
    scene = bge.logic.getCurrentScene()
    
    # get matID for the movie screen 
    matID = bge.texture.materialID(obj, "MA" + obj['material'])
    print(matID)
    # get the texture
    video = bge.texture.Texture(obj, matID)
    
    # get the name of the movie
    movieName = obj['movie']
    soundName = obj['sound']
    
    # get movie path
    movie = bge.logic.expandPath('//sounds/' + movieName)
    sound = aud.Factory.file((bge.logic.expandPath('//sounds/' + soundName))
    
    # get movie
    video.source = bge.texture.VideoFFmpeg(movie)
    
    # set scaling
    video.source.scale = True # save mirror as an object variable
    obj["Video"] = video


    # check for optional loop property
    if "loop" in obj: # loop it forever
        if obj['loop'] == True:
            video.source.repeat = -1 # no looping
        else:
            video.source.repeat = 0
            
    # start the video
    video.source.play()
    
    aud.device().play(sound)
        
#LE

Hello! Could you share a .blend with the video file and the audio file please?

Here,

this is the file i found from https://www.youtube.com/watch?v=P2W_fQayYcA

He plays the soundfile with an always sensor as you can see in file. but for somereason, you can just hear the sound when you are on the current scene, when you start from another scene and set the scene to it, it gets muted by itself. I think it works better with python?

Attachments

sample.zip (2.88 MB)

Are you trying to make that:

? Sorry if I did not understand the question… click on the plane to go to “scene” from “menu”.

the file was not mine, i dont know what that is for too. it was like that o.o

your file seems work well, i will test it abit more out

thanks!!

IT works , perfectly, thanks again youle