-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS 16][video_player] Some videos play only audio with no video #111457
Comments
Hi @collinNewCode, Please provide your Also, what version of Thank you |
I have the same problem func copyPixelBuffer always returns null video_player version: 2.4.7 |
video_player version: 2.4.7 |
I can reproduce the issue with the code sample provided above. Edit: I only tested on iOS 16 since I do not have an iOS 15 device at the moment videos
swiftUI sampleimport AVKit
import SwiftUI
struct ContentView: View {
let videoURL = "https://service.beta.sanjieke.cn/video/media/11244355/608p.m3u8?user_id=18942194&class_id=33254014&time=1663055202&nonce=868849&token=73daa6bce6e2643a3a9d2f28f3385ce86fa5ec82"
@State var showingErrorAlert = false
@State var errorMessage = ""
@State var alertTitle = ""
@State var player : AVPlayer = AVPlayer()
var body: some View {
VideoPlayer(
player: player
).frame(height: 400)
.onAppear(perform: playVideo)
.alert(alertTitle, isPresented: $showingErrorAlert) {
Button("OK") {}
} message: {
Text(errorMessage)
}
}
func playVideo() -> Void {
guard let url = URL(string: videoURL) else {
alertTitle = "Error"
errorMessage = "Unable to play video"
showingErrorAlert = true
return
}
player = AVPlayer(url: url)
player.play()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
} flutter sampleimport 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
void main() {
runApp(
const MaterialApp(
home: MyVideo(),
),
);
}
class MyVideo extends StatefulWidget {
const MyVideo({Key? key}) : super(key: key);
@override
State<MyVideo> createState() => _MyVideoState();
}
class _MyVideoState extends State<MyVideo> {
VideoPlayerController? _controller;
@override
void initState() {
super.initState();
init();
}
@override
void dispose() {
_controller?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("My Video"),
),
body: Center(
child: _controller!.value.isInitialized
? AspectRatio(
aspectRatio: _controller!.value.aspectRatio,
child: VideoPlayer(_controller!),
)
: Container(
child: const Text('loading...'),
),
),
);
}
Future<void> init() async {
_controller = VideoPlayerController.network(
'https://service.beta.sanjieke.cn/video/media/11244355/608p.m3u8?user_id=18942194&class_id=33254014&time=1663055202&nonce=868849&token=73daa6bce6e2643a3a9d2f28f3385ce86fa5ec82',
);
_controller?.addListener(() {
setState(() {});
});
await _controller?.initialize();
_controller?.play();
}
} flutter doctor -v
|
@danagbemava-nc |
Not that I'm aware of at the moment. Someone from the plugins team will take a look at this soon |
I was able to reproduce. The |
yes,do u have a solution now? |
@collinNewCode not yet, but i found this similar problem. It was 5 years ago, but could be same problem, just with different format |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
I'm still looking into this. If you find anything that might be helpful, feel free to share as well. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This is actively being worked on. Please avoid commenting “me too”, “+1”, or similar on issues. Instead, please add a thumbs-up reaction to the issue to avoid adding noise. If you’d like to receive updates, click the subscribe button in the right-hand column. |
Update: found some leads. Putting up a PR soon. |
Update: It worked! I am adding some unit tests and will put up a PR soon. But in case you are curious (it's a pretty tricky one), here's some info: ResearchThere aren't too much info online. It seems to be by design that only Apple's For example, this unresolved issue (5 years ago, but could be the same issue under different format):
Another hint is that iOS 16 introduced a new API
Reverse EngineeringI almost concluded that there's no way to solve it. But i was wondering "how did Apple solve it in
If I were to design AVFoundation, I would probably make it a layered structure, so that the "unlocked" pixel buffers can be piped downstream. This mean that "unlocking" probably happens towards the upstream, hence all outputs (including ours!) can be granted the access. Something like this: graph TD;
A[upstream input]-->B[...];
B-->C[_unlock, hypothetical private API used by AVPlayerLayer];
C-->D[...];
D-->E[...]
E-->F[output 1];
E-->G[output 2];
E-->H[output used by AVPlayerLayer];
E-->I[output used by us];
To verify this hypothesis, I created a dummy This tells 3 things:
Now based on all the above info, this is what I guess Apple's implementation of AVPlayerLayer is:
So in conclusion, all we need to do is to have an invisible AVPlayerLayer to concurrently play the video, which should invoke this hypothetical And it worked :) FutureIt is pretty obvious that Apple's intention is to only allow To follow this spirit, in the future we should probably rely on platform views with |
Are there memory or performance implications of doing this? |
@jmagman my guess is very minimal because it's not rendered on screen. But let me try and compare. |
Approximately when the new version will be released? |
@Adherentman it should already be released when the PR is landed. Can you update and see if the issue is fixed? |
What do I need to do to test? In pub.dev I checked video_player plugin version 2.4.7. The version of video_player_avfoundation in the video_player plugin of the main branch in the github repository is 2.2.17 |
@Adherentman Hmmm, I saw that video_player_avfoundation in pub.dev is still 2.3.5 (link). For some reason my update (2.3.6) is not published immediately. I thought the package is always auto released? Maybe the release process is broken? Let me take a look. |
2.3.6 is now available. It was delayed due to https://github.com/flutter/plugins/actions/runs/3109769619 which failed on |
@jmagman Gotcha. The website still shows 2.3.5 though: https://pub.dev/packages/video_player_avfoundation/versions |
FYI there are some issue releasing it. It's being discussed in the discord channel. The sheriff will release it tomorrow. |
|
It's work. Thanks! |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
the video_player plugin to play AES-128 encrypted m3u8, the audio is working,but the video is black screen.
It was normal before iOS16.
Unencrypted m3u8 seems to be normal.
Can anyone give me some guidance?
The text was updated successfully, but these errors were encountered: