Skip to content

Commit d0ace3e

Browse files
authored
Fix iOS Seek Time Issue ( Issue #72 ) (#75)
1 parent 42fa598 commit d0ace3e

File tree

8 files changed

+58
-25
lines changed

8 files changed

+58
-25
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
## 3.0.3
2+
* Updates MobileVLC to fix a bug on iOS with Seek Time. See (https://github.com/solid-software/flutter_vlc_player/issues/72). Also adds seek bar to example player for demonstration purposes.
3+
credits to Mitch Ross (https://github.com/mitchross)
4+
15
## 3.0.2
2-
* Updates MobileVLC to fix a bug on ios with HLS Streaming on VLCKit itself. See (https://code.videolan.org/videolan/VLCKit/-/issues/368),
6+
* Updates MobileVLC to fix a bug on iOS with HLS Streaming on VLCKit itself. See (https://code.videolan.org/videolan/VLCKit/-/issues/368),
37
credits to Mitch Ross (https://github.com/mitchross)
48

59
## 3.0.1

example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
}
66

77
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.6.3'
8+
classpath 'com.android.tools.build:gradle:4.0.0'
99
}
1010
}
1111

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Mar 11 22:39:55 EDT 2020
1+
#Mon Jul 06 16:18:01 EDT 2020
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

example/ios/Flutter/.last_build_id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9a6723ad18e3f950fccdc81adda11616
1+
f1df2ffda6f2083c9121914530433089

example/lib/main.dart

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'dart:async';
12
import 'dart:typed_data';
23

34
import 'package:flutter/material.dart';
@@ -28,6 +29,8 @@ class MyAppScaffoldState extends State<MyAppScaffold> {
2829
VlcPlayerController _videoViewController;
2930
VlcPlayerController _videoViewController2;
3031
bool isPlaying = true;
32+
double sliderValue = 0.0;
33+
double currentPlayerTime = 0;
3134

3235
@override
3336
void initState() {
@@ -45,6 +48,18 @@ class MyAppScaffoldState extends State<MyAppScaffold> {
4548
setState(() {});
4649
});
4750

51+
Timer.periodic(Duration(seconds: 1), (Timer timer) {
52+
String state = _videoViewController2.playingState.toString();
53+
if (this.mounted) {
54+
setState(() {
55+
if (state == "PlayingState.PLAYING" &&
56+
sliderValue < _videoViewController2.duration.inSeconds) {
57+
sliderValue = _videoViewController2.position.inSeconds.toDouble();
58+
}
59+
});
60+
}
61+
});
62+
4863
super.initState();
4964
}
5065

@@ -94,12 +109,24 @@ class MyAppScaffoldState extends State<MyAppScaffold> {
94109
),
95110
),
96111
),
97-
FlatButton(
98-
child: isPlaying ? Icon(Icons.pause) : Icon(Icons.play_arrow) ,
99-
onPressed: () => {
100-
playOrPauseVideo()
101-
}
112+
Slider(
113+
activeColor: Colors.white,
114+
value: sliderValue,
115+
min: 0.0,
116+
max: _videoViewController2.duration == null
117+
? 1.0
118+
: _videoViewController2.duration.inSeconds.toDouble(),
119+
onChanged: (progress) {
120+
setState(() {
121+
sliderValue = progress.floor().toDouble();
122+
});
123+
//convert to Milliseconds since VLC requires MS to set time
124+
_videoViewController2.setTime(sliderValue.toInt() * 1000);
125+
},
102126
),
127+
FlatButton(
128+
child: isPlaying ? Icon(Icons.pause) : Icon(Icons.play_arrow),
129+
onPressed: () => {playOrPauseVideo()}),
103130
FlatButton(
104131
child: Text("Change URL"),
105132
onPressed: () => _videoViewController.setStreamUrl(
@@ -134,20 +161,19 @@ class MyAppScaffoldState extends State<MyAppScaffold> {
134161
}
135162

136163
void playOrPauseVideo() {
137-
String state = _videoViewController.playingState.toString();
138-
139-
if ( state == "PlayingState.PLAYING" ){
140-
_videoViewController.pause();
141-
setState(() {
142-
isPlaying = false;
143-
});
164+
String state = _videoViewController2.playingState.toString();
165+
166+
if (state == "PlayingState.PLAYING") {
167+
_videoViewController2.pause();
168+
setState(() {
169+
isPlaying = false;
170+
});
144171
} else {
145-
_videoViewController.play();
146-
setState(() {
172+
_videoViewController2.play();
173+
setState(() {
147174
isPlaying = true;
148-
});
175+
});
149176
}
150-
151177
}
152178

153179
void _createCameraImage() async {

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Demonstrates how to use the flutter_vlc_player plugin.
33
publish_to: 'none'
44

55
environment:
6-
sdk: ">=2.0.0-dev.68.0 <3.0.0"
6+
sdk: ">=2.2.0 <3.0.0"
77

88
dependencies:
99
flutter:

ios/Classes/SwiftFlutterVlcPlayerPlugin.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,12 @@ public class VLCView: NSObject, FlutterPlatformView {
134134
return
135135

136136
case .setTime:
137-
138-
let time = VLCTime(number: arguments["time"] as? NSNumber)
137+
let setTimeInMillisecondsAsString = arguments["time"] as? String
138+
let newTime = NSNumber(value:(setTimeInMillisecondsAsString! as NSString).doubleValue)
139+
let time = VLCTime(number: newTime )
139140
self.player.time = time
141+
142+
140143
result(nil)
141144
return
142145

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_vlc_player
22
description: A VLC-powered alternative to Flutter's video_player. Supports multiple players on one screen.
3-
version: 3.0.2
3+
version: 3.0.3
44
homepage: https://github.com/solid-software/flutter_vlc_player
55

66
environment:

0 commit comments

Comments
 (0)