在Google Chrome中打开原生播放器中的视频网址

时间:2015-12-29 18:26:48

标签: javascript android google-chrome android-intent video

我尝试使用直接从Google Chrome启动的默认Android播放器打开远程视频(让我们说它位于if (self.asyncFetchResult) { [self.asyncFetchResult.progress cancel]; } NSFetchRequest* fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"OfflineFeature"]; fetchRequest.predicate = [NSPredicate predicateWithFormat:@"layers.layerName in %@ AND xMax >= %lf AND xMin <= %lf AND yMax >= %lf AND yMin <=%lf", allLayerNames, bufferedEnvelope.xmin,bufferedEnvelope.xmax,bufferedEnvelope.ymin,bufferedEnvelope.ymax]; NSAsynchronousFetchRequest* asyncFetchRequest = [[NSAsynchronousFetchRequest alloc] initWithFetchRequest:fetchRequest completionBlock:^(NSAsynchronousFetchResult* result) { if (![result.progress isCancelled]) { allFeatures = result.finalResult; dispatch_async(dispatch_get_main_queue(), ^{ //Bunch of code to use the results }); } }]; MVAppDelegate* appDelegate = (MVAppDelegate*)[[UIApplication sharedApplication] delegate]; __weak typeof(self) weakSelf = self; [appDelegate.managedObjectContext performBlock:^{ NSProgress* progress = [NSProgress progressWithTotalUnitCount:1]; [progress becomeCurrentWithPendingUnitCount:1]; NSError* error; weakSelf.asyncFetchResult = [appDelegate.managedObjectContext executeRequest:asyncFetchRequest error:&error]; if (error) { NSLog(@"Error performing asynchronous fetch request.\n%@", error); } [progress resignCurrent]; }]; ),利用该品牌新http://www.example.com/video.mp4

这是我通过intent://标记调用的URI:

href

当然,此URI不起作用,Chrome会返回错误&#34;无法执行导航&#34;。我还尝试了省略intent://www.example.com/video.mp4#Intent;scheme=file;action=android.intent.action.VIEW;end; 的相同URI。

以下是我一直关注的文档:https://developer.chrome.com/multidevice/android/intents

提前致谢!

1 个答案:

答案 0 :(得分:6)

快速浏览AOSP中的Gallery App可以显示它可以从浏览器启动。 It has a category of BROWSABLE and DEFAULT。这意味着给定正确的意图URL,您应该能够启动它。

显然指定一个包应该有用,但这不灵活,如果有两个图库应用程序会怎么样。

以下Intent方案网址有效:

intent://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4#Intent;action=android.intent.action.VIEW;scheme=http;type=video/mp4;end

注意:

  1. scheme = http(需要是那个或https),
  2. 在域之前有一个//,如果不存在,则在播放器
  3. 中没有正确构造URL
  4. action = android.intent.action.VIEW
  5. type = video / mp4 - 如果没有,视频将在浏览器中打开
  6. 我创建了demo that works