mirror of
				https://github.com/Rafostar/clapper.git
				synced 2025-10-31 10:25:45 +01:00 
			
		
		
		
	Support for multiple media files
This enables support for starting media player with more than one file path specified. When a file playback finishes, next is loaded automatically.
This commit is contained in:
		| @@ -264,10 +264,8 @@ var App = GObject.registerClass({ | ||||
|          this.player.widget.disconnect(this.playerDrawSignal); | ||||
|          this.emit('ready', true); | ||||
|  | ||||
|          if(!this.playlist.length) | ||||
|             return; | ||||
|  | ||||
|          this.player.set_media(this.playlist[0]); | ||||
|          if(this.playlist.length) | ||||
|             this.player.set_playlist(this.playlist); | ||||
|     } | ||||
|  | ||||
|     _onPlayerStateChanged(self, state) | ||||
|   | ||||
| @@ -57,8 +57,12 @@ class ClapperPlayer extends GstPlayer.Player | ||||
|         this.widget = gtkglsink.widget; | ||||
|         this.state = GstPlayer.PlayerState.STOPPED; | ||||
|  | ||||
|         this.connect('state_changed', this._onStateChanged.bind(this)); | ||||
|         this.connect('uri_loaded', this._onUriLoaded.bind(this)); | ||||
|         this._playlist = []; | ||||
|         this._trackId = 0; | ||||
|  | ||||
|         this.connect('state-changed', this._onStateChanged.bind(this)); | ||||
|         this.connect('uri-loaded', this._onUriLoaded.bind(this)); | ||||
|         this.connect('end-of-stream', this._onStreamEnded.bind(this)); | ||||
|         this.widget.connect('destroy', this._onWidgetDestroy.bind(this)); | ||||
|     } | ||||
|  | ||||
| @@ -83,6 +87,22 @@ class ClapperPlayer extends GstPlayer.Player | ||||
|         this.set_uri(uri); | ||||
|     } | ||||
|  | ||||
|     set_playlist(playlist) | ||||
|     { | ||||
|         if(!Array.isArray(playlist)) | ||||
|             return; | ||||
|  | ||||
|         this._trackId = 0; | ||||
|         this._playlist = playlist; | ||||
|  | ||||
|         this.set_media(this._playlist[0]); | ||||
|     } | ||||
|  | ||||
|     get_playlist() | ||||
|     { | ||||
|         return this._playlist; | ||||
|     } | ||||
|  | ||||
|     seek_seconds(position) | ||||
|     { | ||||
|         this.seek(position * 1000000000); | ||||
| @@ -115,6 +135,14 @@ class ClapperPlayer extends GstPlayer.Player | ||||
|             this.loop.quit(); | ||||
|     } | ||||
|  | ||||
|     _onStreamEnded(player) | ||||
|     { | ||||
|         this._trackId++; | ||||
|  | ||||
|         if(this._trackId < this._playlist.length) | ||||
|             this.set_media(this._playlist[this._trackId]); | ||||
|     } | ||||
|  | ||||
|     _onUriLoaded() | ||||
|     { | ||||
|         this.play(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user