examples: Start playback after assembling app window

This is the correct order of how things should be done, so teach what is right
This commit is contained in:
Rafał Dzięgiel
2024-06-29 15:07:54 +02:00
parent 99708e1267
commit 63f2fa1946
2 changed files with 8 additions and 8 deletions

View File

@@ -32,17 +32,17 @@ def on_activate(app):
video.props.player.props.queue.set_progression_mode(Clapper.QueueProgressionMode.CAROUSEL)
video.props.player.set_autoplay(True)
# Assemble window
video.add_fading_overlay(controls)
win.set_child(video)
win.present()
# Create and add media for playback
item_1 = Clapper.MediaItem(uri='http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4')
item_2 = Clapper.MediaItem(uri='http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4')
video.props.player.props.queue.add_item(item_1)
video.props.player.props.queue.add_item(item_2)
# Assemble window
video.add_fading_overlay(controls)
win.set_child(video)
win.present()
# Create a new application
app = Adw.Application(application_id='com.example.ClapperDownloadCache')
app.connect('activate', on_activate)

View File

@@ -24,9 +24,6 @@ def on_activate(app):
# more than simply inverting fullscreen on the whole window).
video.connect('toggle-fullscreen', on_toggle_fullscreen, win)
# Enable autoplay
video.props.player.set_autoplay(True)
# Create and add media for playback. First added media item to empty
# playback queue will be automatically selected.
item = Clapper.MediaItem(uri='http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4')
@@ -37,6 +34,9 @@ def on_activate(app):
win.set_child(video)
win.present()
# Start playback
video.props.player.play()
# Create a new application
app = Adw.Application(application_id='com.example.ClapperSimple')
app.connect('activate', on_activate)