• 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
3. Dialogs & Video Playback
#1
UPDATE: If using the new Python Koding framework we recommend watching episodes 1-5 only. Also note that some features you learn in these are now fairly redundant as Python Koding can handle them in a simpler way but the information given in those episodes is (for the most part) still relevant and a great starting point.



In this episode we take a look at the xbmcgui module and create the OK and YES/NO diailogs.

By combining the above dialogs with some if statements we worked in the previous guides we then get Kodi to play an online video and even give the choice of watching a trailer.

Please only use this thread for queries relating to this video, thank you.




IMPORTANT:
NO LOG == NO PROBLEM
Away
  Reply
#2
Hi whufclee i have been watching your tutorial videos

im a little confused watching - Python Koding 3: Dialogs & Playing Videos

below is my dialog code so far.

dialog = xbmcgui.Dialog()
dialog.ok("Welcome To My Addon")  # Dialog box number 1
choice = dialog.yesno("Would you Like To watch my intro video?",yeslabel="Continue",nolabel="Skip")  #Dialog box number2
if choice == False:Video
video = "http://mywebsite/intro.mp4"
xbmc.Player().play(video)

Dialog box number1 works fine (i just click ok)
when i click "continue" in dialog box number2 the video plays fine.
when i click "Skip" in dialog box number2 the video also plays again how do i just skip the intro.mp4?
after clicking "Skip" i want my addon to continue to launch.
  Reply
#3
Can you please use the code tags next time you post code onto the forum. I think the forum formatting may be messing that up a bit.

My best guess is its just a simple indentation error. Should look something like this:
Code:
If choice:
    video = "http://mywebsite/intro.mp4
    xbmc.Player().play(video)


So everything you only want to happen if choice is true should be indented in its own little block.


Sent from my MI MAX using Tapatalk
IMPORTANT:
NO LOG == NO PROBLEM
Away
  Reply
#4
Hmm think replying on my phone isn't working, the 2 lines after choice: should be indented but on my phone for some reason it's not showing like that

Sent from my MI MAX using Tapatalk
IMPORTANT:
NO LOG == NO PROBLEM
Away
  Reply
#5
Thankyou for your earlier reply whufclee, ive managed to get my intro working fine now,
by selecting the "continue" button intro plays fine.
by selecting the "skip intro" button it goes straight to my home screen of my addon.
thats exactly what i wanted....thanks again

I now have another little problem,
every time i select a catergory in my addon i.e "movies" the dialog screen pops up again,
infact it does it when i come out of any section and select another section witin my addon.
do you know a way to stop this as i only want my "dialog" screen to popup once upon my addon starting?

my example code is below

Code:
#################### Opening Screen and intro ####################
dialog = xbmcgui.Dialog()
dialog.ok("Welcome To My Addon")
choice = dialog.yesno("Would you Like To watch my intro video?", yeslabel="Continue",nolabel="Skip Intro")
if choice:
   video = "http://mywebsite.com/intro.mp4"
   xbmc.Player().play(video)
  Reply
#6
After looking around at differnt dialog code,ive hit a brick wall :-(

Kodi Development 17.0 for Binary and Script based Add-Ons

Code:
dialog = xbmcgui.Dialog()
ret = dialog.multiselect("Choose something", ["Foo", "Bar", "Baz"], preselect=[1,2])

The code above also works but does exactly same, every time i select a differnt section within my addon the dialog box appears again and again.
Is there a line of code that will just presnt the dialog screens once my addon starts?
  Reply
#7
I would highly suggest using one of the Python Koding templates which can be auto generated for you at totalrevolution.tv - that has everything setup ready to go and has far better routing methods than explained in the original Python Koding season 1 videos.

However if you'd prefer to use your existing code base then the fix should be simple. If I'm understanding correctly you're getting that initial dialog every time you do some kind of action in the add-on?

If that's the case then it sounds as though you don't have that dialog inside a function.

Every time you click on a new menu all of the code in your default is run again and because you've not added that dialog into some kind of function it's going to keep running it over and over again because it hasn't been told not to.

You could just put it inside the function which shows your first set of menus - I think if you're using those old guides I called that function Categories()?

What you will find though is the dialog will appear every time you go back to that menu so it will get very annoying, what you probably want to do is set an add-on setting to True once the dialog has appeared and then never show it again, so your dialog code would be in an "if <addon_setting> == True:" statement.

If you're going to go that route then I can't emphasise how much easier it would be for you to switch to the Python Koding framework, if you've got no idea what I'm on about please watch my last video I uploaded to YouTube or take a look on the blog site Smile
IMPORTANT:
NO LOG == NO PROBLEM
Away
  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  4. Creating playable video links whufclee 2 357 05-08-2017, 04:13 PM
Last Post: whufclee

Forum Jump:


Users browsing this thread: 1 Guest(s)