Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[open] gst player scripting

edited September 2015 in OpenSesame

Hey,

I am setting up an eye-tracking experiment involving a video presentation and a concurrent auditory response task, which is timed to certain frames. For now I have put an inline-script and the video player in the parallel component. In the script that is executed after a new frame is displayed, the current frame no. is written to an opensesame variable such that I can assess it in the inline-script that is running in parallel and checks if a certain frame no. is reached and if so plays a sound and waits for a keyboard response.

However I wonder if there is a simpler method without using the parallel plugin, but just scripting on the frame rendering loop of the video player? The problem with the existing possibility of executable python code after every frame is that it appears not to share variables with previous inline-scripts, for e.g. component preparation.

Any help is highly appreciated!

Cheers, Steffen

Comments

  • edited 12:46AM

    Hi Steffen,

    Yes it is possible to script on the frame rendering loop of the video player (if you're talking about the media_player_vlc item?). Clicking on that item in the overview window, you can set the Call custom python code parameter to "after every frame". Right below that is the box in which you can insert your code.
    You have to create a variable with which you keep count of the frames. This is done in an inline_script prior to the video item (with a simple frame=0). In the video item, you insert the line frame += 1. In the same code window you would have to implement code to play the audio stimulus at the desired frame (e.g. if frame== 200: etc.).

    Cheers,

    Josh

  • edited 12:46AM

    I am using the media_player_gst item, because I got some problems using the vlc item. Well your idea is quite what I had in mind, but it seems that when I define a variable in a prior inline script it is not accessible in the custom python code. Thats my trouble.

  • edited 12:46AM

    Ah, that's because you need to 'set' the variable, making it available outside of the inline_script you created it in:

      frame = 0
      exp.set('frame', frame)
    

    And in the custom python code window:

      exp.set('frame', exp.get('frame') += 1)
    

    Hope this helps.

    Josh

  • edited 12:46AM

    Yeah I do that already, however I cannot set e.g. a sound component in an opensesame variable thus I would like to initialise the component in a prior inline script and access it in the custom code. However that seems not possible and I have to use an inline script which runs in parallel and checks the frame no. (set in an opensesame variable in the custom code). Thus I would like to know if I miss something and somehow it is possible to access inline script python variables from within the custom code, or if the whole media_player_gst item code can be accessed in another way like in psychopy?

  • edited 12:46AM

    Ok I solved the issue by making some modifications to the media_player_gst.py file, i.e. executing the custom python code with the globals of the opsensesame python_workspace:

    exec(self.custom_event_code, self.main_player.experiment.python_workspace._globals, locals())
    

    This way I can run the video player without the parallel plugin. However, now taking the keyboard responses without delaying the video causes trouble. Any ideas?

  • edited 12:46AM

    Hi Steffen,

    The only thing I can think of, is to implement the keyboard response inside the custom code window, rather than to use a keyboard_response item (don't know if you did?). The idea would be to check every frame if a key was pressed - and of course, the possiblity to press a key should only become available after the specifically desired frame.

    At the desired frame you could start a timer, (start = self.time()), along with the variable stimulus_onset = True. From then on, every frame you could check if a key was pressed (see also: http://osdoc.cogsci.nl/python/keyboard/#function-keyboardflush. The keyboard command would be preceded by an "if stimulus_onset == True:" line, so that it doesn't check for keyboard responses prior to stimulus onset). If a key was pressed, the response time would be self.time() - start.
    The only problem with this method would be that the temporal resolution of your response times isn't too great, as you only check for responses every frame.

    Cheers,

    Josh

  • edited September 2015

    Thanks for your advice! Yes temporal resolution really goes down. I managed to solve the problem now using the ThreadPool class from the Python multiprocess module. It works really fine. However, I have the problem that it does not work in fullscreen mode, the video would at some point stop and the experiment finishes normally. But this is directly related to the media_player_gst implementation I think. I will set up another discussion about this. http://www.cogsci.nl/forum/index.php?p=/discussion/1630/media_player_gst-not-working-in-fullscreen-mode#Item_1

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games