Strange mediaview problem

Post

Posted
Rating:
#1 (In Topic #1480)
Regular
rj71 is in the usergroup ‘Regular’
I'm working on an app that heavily uses mediaview. It's basically a movies/internet streams app. The problem is sometimes when mediaview can't play the movie or maybe there is a problem with the stream it literally "pops" out of the form into a new window of its own. Technically, it's the next movie/stream I try to play that pops the video player out. It seems to occur more with streams that are either not there or some other unknown problem. I do have error handling so why would this happen?  Here's my error handling…it's pretty simple:

Code (gambas)

  1. MediaView1.url = label4.Text
  2. Wait 0.1
  3. Try MediaView1.Play
  4.    Message("Unable to connect!")
  5. '(after user clicks ok on the messagebox, usually the next stream I try to play is when it pops the mediaview player out)
  6.    'cant connect to stream
  7.   'should play
  8.  
  9.  
Online now: No Back to the top

Post

Posted
Rating:
#2
Banned
I would guess it's your code somewhere opening the form again in it's play setup.
post a sample project

Also i'm not sure that type of error handling will work and you should probably check MediaView.State

Code (gambas)

  1.  
  2. MediaView1.url = label4.Text
  3. Dim sPlaytError As String
  4. Try MediaView1.Play
  5. If Error then sPlayError = "\n" & Error.Text
  6.  If sPlayError Or If MediaView1.State <> Media.Playing Then
  7.    Message("Unable to Play video!" & sPlayError)
  8.    'cant connect to stream
  9.   'should play
  10.  
  11.  

I'll need to see all the code though, post a sample project that shows the bug.
snippets of code are just not enough to find the problem.
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
rj71 is in the usergroup ‘Regular’

BruceSteers said

I would guess it's your code somewhere opening the form again in it's play setup.
post a sample project

Also i'm not sure that type of error handling will work and you should probably check MediaView.State

Code (gambas)

  1.  
  2. MediaView1.url = label4.Text
  3. Dim sPlaytError As String
  4. Try MediaView1.Play
  5. If Error then sPlayError = "\n" & Error.Text
  6.  If sPlayError Or If MediaView1.State <> Media.Playing Then
  7.    Message("Unable to Play video!" & sPlayError)
  8.    'cant connect to stream
  9.   'should play
  10.  
  11.  

I'll need to see all the code though, post a sample project that shows the bug.
snippets of code are just not enough to find the problem.

I'll work on a sample project. Really busy today but I'll upload whenever I can. Thanks Bruce.
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
rj71 is in the usergroup ‘Regular’
I was able to make a very simple sample app. The original app has hundreds/thousands of streams I have in a mysql db (got those urls from github so nothing illegal I think!  :lol: ). Obviously can't do that here so the sample app has 2 buttons - 1 good stream and 1 bad stream. Please see the Textlabel for more info.

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#5
Banned
There's nothing in that zip file.

Maybe open the project in the IDE and select the menu Project / Make source archive

or select "Show hidden files" in your file manager before compressing the folder.
Online now: No Back to the top

Post

Posted
Rating:
#6
Regular
rj71 is in the usergroup ‘Regular’

BruceSteers said

There's nothing in that zip file.

Maybe open the project in the IDE and select the menu Project / Make source archive

or select "Show hidden files" in your file manager before compressing the folder.
Whoops! Sorry about that. Forgot the files were hidden. Here you go…

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#7
Banned
 I can't reproduce the problem.

It opens in the main form all the time.

but i also get no error Message() call either with the first bad link (just shows an error message in the mediaview).

I suggest trying a Wait call directly after calling Message()

  Message("Unable to connect!")
  Wait

This gives the event loop a chance to cycle and has fixed what i think might have been a similar issue for me once.
I think when Message() runs Application.MainWindow changes and needs to restore properly.

Does the popup window happen if you do not use Message() ?
Online now: No Back to the top

Post

Posted
Rating:
#8
Regular
rj71 is in the usergroup ‘Regular’

BruceSteers said

I can't reproduce the problem.

It opens in the main form all the time.

but i also get no error Message() call either with the first bad link (just shows an error message in the mediaview).

I suggest trying a Wait call directly after calling Message()

  Message("Unable to connect!")
  Wait

This gives the event loop a chance to cycle and has fixed what i think might have been a similar issue for me once.
I think when Message() runs Application.MainWindow changes and needs to restore properly.

Does the popup window happen if you do not use Message() ?

Yes the mediaview pops out whether I use Message() or not. I guess if you couldn't reproduce then it's obviously a me problem. I have 3 different machines all running Debian 12 with Gambas 3.18 and it happens on all 3.  Trixie comes out in June if I remember correctly so I'll hold out until then and then upgrade one of the machines and see if it persists. In the meantime I'll just experiment with different things and see what happens.
I did try your drop-in mediaview component you suggested to me a few months ago in one of my posts but I couldn't get it to work….I'll just wait until Trixie is released.
Thanks Bruce!
Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Administrator
sholzy is in the usergroup ‘unknown’
 It's working for me. Button 1 produces a pop up error that it can't connect. Button 2 plays the stream.

I'm on Debian 12 and Gambas 3.18.0.

Cancel that…
Button 2 works as should until I click button 1 and get the popup message. Next time I click button 2 the stream opens in new window.

sholzy
Gambas One Site Director

To report bugs in the Gambas IDE:
Official Gambas Bug Tracker
Online now: No Back to the top

Post

Posted
Rating:
#10
Regular
rj71 is in the usergroup ‘Regular’

sholzy said

It's working for me. Button 1 produces a pop up error that it can't connect. Button 2 plays the stream.

I'm on Debian 12 and Gambas 3.18.0.

Cancel that…
Button 2 works as should until I click button 1 and get the popup message. Next time I click button 2 the stream opens in new window.
Thanks sholzy. I think tomorrow I'll build a vm with a newer version of gambas…maybe ubuntu 24. I'll see if I can reproduce the problem on that.
Online now: No Back to the top

Post

Posted
Rating:
#11
Avatar
Administrator
sholzy is in the usergroup ‘unknown’
 I use MediaView (6 actually) in my security camera project and don't get the same popup window issue as you.

I tried creating a basic test project using the same project properties as my security project. I still had the same issue with a new window popping up. If I find something useful, I'll post it here.

I also noticed you are using "Quit" to close your project. Use "Me.Close" instead. "Me.Close" allows Gambas to clean things up before closing the project.

sholzy
Gambas One Site Director

To report bugs in the Gambas IDE:
Official Gambas Bug Tracker
Online now: No Back to the top

Post

Posted
Rating:
#12
Regular
rj71 is in the usergroup ‘Regular’

sholzy said

I use MediaView (6 actually) in my security camera project and don't get the same popup window issue as you.

I tried creating a basic test project using the same project properties as my security project. I still had the same issue with a new window popping up. If I find something useful, I'll post it here.

I also noticed you are using "Quit" to close your project. Use "Me.Close" instead. "Me.Close" allows Gambas to clean things up before closing the project.
Thanks sholzy!
Online now: No Back to the top

Post

Posted
Rating:
#13
Regular
rj71 is in the usergroup ‘Regular’
I never did figure out why the mediaview pops out of the form but I did find a workaround if anyone is interested. Using Bruce Steer's dynamic component creation code, I just delete the mediaview, wait 0.5 then recreate it every time there is an attempt to play any stream. That seems to prevent the mediaview from popping out of the form. Maybe not the best way to deal with it but it works  :P

Attachment
Online now: No Back to the top
1 guest and 0 members have just viewed this.