@@ -45,7 +45,7 @@ extension YouTubePlayer.Options {
45
45
originURL: URL ?
46
46
) throws {
47
47
// Retrieve Player Configuration as JSON
48
- var playerConfiguration = try playerConfiguration. json ( )
48
+ var playerConfigurationJSON = try playerConfiguration. json ( )
49
49
// Initialize Configuration
50
50
var configuration : [ String : Any ] = [
51
51
CodingKeys . width. rawValue: " 100% " ,
@@ -72,26 +72,32 @@ extension YouTubePlayer.Options {
72
72
// Check if a start seconds are available
73
73
if let startSeconds = startSeconds {
74
74
// Set start time on player configuration
75
- playerConfiguration [
75
+ playerConfigurationJSON [
76
76
YouTubePlayer . Configuration. CodingKeys. startTime. rawValue
77
77
] = startSeconds
78
78
}
79
+ // Check if loop is enabled
80
+ if playerConfiguration. loopEnabled == true {
81
+ // Add playlist parameter with video id
82
+ // as this parameter is required to make looping work
83
+ playerConfigurationJSON [ YouTubePlayer . Configuration. ListType. playlist. rawValue] = id
84
+ }
79
85
case . playlist( let id, _, _) :
80
86
// Set playlist
81
- playerConfiguration [
87
+ playerConfigurationJSON [
82
88
YouTubePlayer . Configuration. CodingKeys. listType. rawValue
83
89
] = YouTubePlayer . Configuration. ListType. playlist. rawValue
84
90
// Set playlist id
85
- playerConfiguration [
91
+ playerConfigurationJSON [
86
92
YouTubePlayer . Configuration. CodingKeys. list. rawValue
87
93
] = id
88
94
case . channel( let name, _, _) :
89
95
// Set user uploads
90
- playerConfiguration [
96
+ playerConfigurationJSON [
91
97
YouTubePlayer . Configuration. CodingKeys. listType. rawValue
92
98
] = YouTubePlayer . Configuration. ListType. userUploads. rawValue
93
99
// Set channel id
94
- playerConfiguration [
100
+ playerConfigurationJSON [
95
101
YouTubePlayer . Configuration. CodingKeys. list. rawValue
96
102
] = name
97
103
case nil :
@@ -101,14 +107,14 @@ extension YouTubePlayer.Options {
101
107
// Check if an origin URL is available
102
108
// and the player configuration doesn't contain an origin
103
109
if let originURL = originURL,
104
- playerConfiguration [ YouTubePlayer . Configuration. CodingKeys. origin. rawValue] == nil {
110
+ playerConfigurationJSON [ YouTubePlayer . Configuration. CodingKeys. origin. rawValue] == nil {
105
111
// Set origin URL
106
- playerConfiguration [
112
+ playerConfigurationJSON [
107
113
YouTubePlayer . Configuration. CodingKeys. origin. rawValue
108
114
] = originURL. absoluteString
109
115
}
110
116
// Set Player Configuration
111
- configuration [ CodingKeys . playerVars. rawValue] = playerConfiguration
117
+ configuration [ CodingKeys . playerVars. rawValue] = playerConfigurationJSON
112
118
// Make JSON string from Configuration
113
119
self . json = try configuration. jsonString ( )
114
120
}
0 commit comments